Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add one error jsp with only a message, remove i18n for authorize exce…
…ption message
  • Loading branch information
Pascarelli Luigi Andrea committed Sep 6, 2013
1 parent 00e9297 commit 6531068
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
7 changes: 2 additions & 5 deletions dspace-api/src/main/resources/Messages.properties
Expand Up @@ -1566,10 +1566,7 @@ jsp.dspace-admin.eperson-main.ResetPassword-error.errormsg = Sorry, an error has
jsp.dspace-admin.eperson-main.ResetPassword.returntoedit = Return to the Administer EPeople page

# login as
jsp.dspace-admin.eperson-main.LoginAs.submit = Login As
jsp.dspace-admin.eperson-main.LoginAs.onlyAdmins = Only site administrators may assume login as another user.
jsp.dspace-admin.eperson-main.LoginAs.onlyAuthenticatedAdmins = Only authenticated users who are administrators may assume the login as another user.
jsp.dspace-admin.eperson-main.LoginAs.notAnotherAdmin = You may not assume the login as another administrator.
jsp.dspace-admin.eperson-main.LoginAs.submit = Login As
jsp.dspace-admin.eperson-main.loginAs.authorize.errormsg = Reason: you may not assume the login as another administrator.
jsp.dspace-admin.eperson-main.loginAs.authorize.title = Authorization Error
jsp.dspace-admin.eperson-main.loginAs.authorize.errormsg = Reason: {0}
jsp.dspace-admin.eperson-main.loginAs.backtoeditpeople = Back to E-people Admin page
Expand Up @@ -43,11 +43,7 @@
*/
public class EPersonAdminServlet extends DSpaceServlet
{

private static final String LOG_MESSAGE_LOGIN_AS_OFF = "jsp.dspace-admin.eperson-main.LoginAs.submit";
private static final String MESSAGE_LOGIN_AS_NOT_ANOTHER_ADMIN = "jsp.dspace-admin.eperson-main.LoginAs.notAnotherAdmin";
private static final String MESSAGE_LOGIN_AS_ONLY_AUTHENTICATED_ADMINS = "jsp.dspace-admin.eperson-main.LoginAs.onlyAuthenticatedAdmins";
private static final String MESSAGE_LOGIN_AS_ONLY_ADMINS = "jsp.dspace-admin.eperson-main.LoginAs.onlyAdmins";

/** Logger */
private static Logger log = Logger.getLogger(EPersonAdminServlet.class);

Expand Down Expand Up @@ -298,7 +294,7 @@ else if (button.equals("submit_login_as"))
{
if (!ConfigurationManager.getBooleanProperty("webui.user.assumelogin", false))
{
throw new AuthorizeException(I18nUtil.getMessage(LOG_MESSAGE_LOGIN_AS_OFF));
throw new AuthorizeException("Turn on webui.user.assumelogin to activate Login As feature");
}
EPerson e = EPerson.find(context, UIUtil.getIntParameter(request,
"eperson_id"));
Expand All @@ -311,7 +307,7 @@ else if (button.equals("submit_login_as"))
// Only super administrators can login as someone else.
else if (!AuthorizeManager.isAdmin(context))
{
throw new AuthorizeException(I18nUtil.getMessage(MESSAGE_LOGIN_AS_ONLY_ADMINS));
throw new AuthorizeException("Only site administrators may assume login as another user.");
}
else
{
Expand All @@ -329,15 +325,13 @@ else if (!AuthorizeManager.isAdmin(context))
Integer authenticatedID = (Integer) session.getAttribute("dspace.current.user.id");
if (context.getCurrentUser().getID() != authenticatedID)
{
throw new AuthorizeException(I18nUtil.getMessage(MESSAGE_LOGIN_AS_ONLY_AUTHENTICATED_ADMINS));
throw new AuthorizeException("Only authenticated users who are administrators may assume the login as another user.");
}

// You may not assume the login of another super administrator
Group administrators = Group.find(context,1);
if (administrators.isMember(e))
{
request.setAttribute("authorize_error_message", MESSAGE_LOGIN_AS_NOT_ANOTHER_ADMIN);
log.warn(new AuthorizeException(I18nUtil.getMessage(MESSAGE_LOGIN_AS_NOT_ANOTHER_ADMIN)));
{
JSPManager.showJSP(request, response,
"/dspace-admin/eperson-loginas-error.jsp");
return;
Expand Down
Expand Up @@ -8,7 +8,7 @@
--%>
<%--
- Page representing an eperson reset password error
- Page representing an eperson loginas error
--%>

Expand All @@ -19,22 +19,14 @@

<%@ page isErrorPage="true" %>
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
<%@page import="javax.servlet.jsp.jstl.fmt.LocaleSupport"%>
<%
Object i18nKey = request.getAttribute("authorize_error_message");
String message = "";
if(i18nKey!=null) {
message = LocaleSupport.getLocalizedMessage(pageContext, i18nKey.toString());
}
request.removeAttribute("authorize_error_message");
%>

<dspace:layout titlekey="jsp.dspace-admin.eperson-main.loginAs.authorize.title">

<%-- <h1>Authorization Required</h1> --%>
<h1><fmt:message key="jsp.dspace-admin.eperson-main.loginAs.authorize.title"/></h1>


<p><fmt:message key="jsp.dspace-admin.eperson-main.loginAs.authorize.errormsg"><fmt:param><%= message %></fmt:param></fmt:message></p>
<p><fmt:message key="jsp.dspace-admin.eperson-main.loginAs.authorize.errormsg"/></p>


<p align="center">
Expand Down

0 comments on commit 6531068

Please sign in to comment.