Remove icon definitions and error message markup from login controller and handle in templates instead.
This commit is contained in:
parent
2c6ddaab64
commit
79da8d30ed
2 changed files with 15 additions and 17 deletions
|
@ -40,10 +40,8 @@ public class FreemarkerSiteAdminController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
// Not logged in: just show login form
|
// Not logged in: just show login form
|
||||||
if (loginHandler == null || !"authenticated".equals(loginStatus)) {
|
if (loginHandler == null || !"authenticated".equals(loginStatus)) {
|
||||||
//return new LoginTemplateHelper(vreq).showLoginPage(vreq, body, config);
|
|
||||||
body.put("loginPanel", new LoginTemplateHelper(vreq).showLoginPage(vreq, body, config));
|
body.put("loginPanel", new LoginTemplateHelper(vreq).showLoginPage(vreq, body, config));
|
||||||
return mergeBodyToTemplate("siteAdmin-main.ftl", body, config);
|
return mergeBodyToTemplate("siteAdmin-main.ftl", body, config);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int securityLevel = Integer.parseInt( loginHandler.getLoginRole() );
|
int securityLevel = Integer.parseInt( loginHandler.getLoginRole() );
|
||||||
|
|
|
@ -38,19 +38,15 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
/** If they are changing their password on first login, show them this form. */
|
/** If they are changing their password on first login, show them this form. */
|
||||||
public static final String TEMPLATE_FORCE_PASSWORD_CHANGE = "login-forcedPasswordChange.ftl";
|
public static final String TEMPLATE_FORCE_PASSWORD_CHANGE = "login-forcedPasswordChange.ftl";
|
||||||
|
|
||||||
|
/** Show error message */
|
||||||
|
public static final String TEMPLATE_SERVER_ERROR = "errorMessage.ftl";
|
||||||
|
|
||||||
public static final String BODY_LOGIN_NAME = "loginName";
|
public static final String BODY_LOGIN_NAME = "loginName";
|
||||||
public static final String BODY_FORM_ACTION = "formAction";
|
public static final String BODY_FORM_ACTION = "formAction";
|
||||||
public static final String BODY_INFO_MESSAGE = "infoMessage";
|
public static final String BODY_INFO_MESSAGE = "infoMessage";
|
||||||
public static final String BODY_ERROR_MESSAGE = "errorMessage";
|
public static final String BODY_ERROR_MESSAGE = "errorMessage";
|
||||||
public static final String BODY_ALERT_ICON_URL = "alertImageUrl";
|
|
||||||
public static final String BODY_CANCEL_URL = "cancelUrl";
|
public static final String BODY_CANCEL_URL = "cancelUrl";
|
||||||
|
|
||||||
/** Use this icon for an info message. */
|
|
||||||
public static final String URL_INFO_ICON = "/images/iconAlert.png";
|
|
||||||
|
|
||||||
/** Use this icon for an error message. */
|
|
||||||
public static final String URL_ERROR_ICON = "/images/iconAlert.png";
|
|
||||||
|
|
||||||
/** If no portal is specified in the request, use this one. */
|
/** If no portal is specified in the request, use this one. */
|
||||||
private static final int DEFAULT_PORTAL_ID = 1;
|
private static final int DEFAULT_PORTAL_ID = 1;
|
||||||
|
|
||||||
|
@ -60,8 +56,8 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
|
|
||||||
/** Version for JSP page */
|
/** Version for JSP page */
|
||||||
public String showLoginPage(HttpServletRequest request) {
|
public String showLoginPage(HttpServletRequest request) {
|
||||||
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
try {
|
try {
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
|
||||||
|
|
||||||
State state = getCurrentLoginState(vreq);
|
State state = getCurrentLoginState(vreq);
|
||||||
log.debug("State on exit: " + state);
|
log.debug("State on exit: " + state);
|
||||||
|
@ -76,7 +72,7 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e);
|
log.error(e);
|
||||||
return "<h2>Internal server error:<br/>" + e + "</h2>";
|
return doTemplate(vreq, showError(request, e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +93,7 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e);
|
log.error(e);
|
||||||
return "<h2>Internal server error:<br/>" + e + "</h2>";
|
return doTemplate(vreq, showError(vreq, e), body, config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,12 +116,10 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
String infoMessage = bean.getInfoMessage();
|
String infoMessage = bean.getInfoMessage();
|
||||||
if (!infoMessage.isEmpty()) {
|
if (!infoMessage.isEmpty()) {
|
||||||
trv.put(BODY_INFO_MESSAGE, infoMessage);
|
trv.put(BODY_INFO_MESSAGE, infoMessage);
|
||||||
trv.put(BODY_ALERT_ICON_URL, UrlBuilder.getUrl(URL_INFO_ICON));
|
|
||||||
}
|
}
|
||||||
String errorMessage = bean.getErrorMessage();
|
String errorMessage = bean.getErrorMessage();
|
||||||
if (!errorMessage.isEmpty()) {
|
if (!errorMessage.isEmpty()) {
|
||||||
trv.put(BODY_ERROR_MESSAGE, errorMessage);
|
trv.put(BODY_ERROR_MESSAGE, errorMessage);
|
||||||
trv.put(BODY_ALERT_ICON_URL, UrlBuilder.getUrl(URL_ERROR_ICON));
|
|
||||||
}
|
}
|
||||||
return trv;
|
return trv;
|
||||||
}
|
}
|
||||||
|
@ -147,11 +141,17 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
String errorMessage = bean.getErrorMessage();
|
String errorMessage = bean.getErrorMessage();
|
||||||
if (!errorMessage.isEmpty()) {
|
if (!errorMessage.isEmpty()) {
|
||||||
trv.put(BODY_ERROR_MESSAGE, errorMessage);
|
trv.put(BODY_ERROR_MESSAGE, errorMessage);
|
||||||
trv.put(BODY_ALERT_ICON_URL, UrlBuilder.getUrl(URL_ERROR_ICON));
|
|
||||||
}
|
}
|
||||||
return trv;
|
return trv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TemplateResponseValues showError(HttpServletRequest request, Exception e) {
|
||||||
|
TemplateResponseValues trv = new TemplateResponseValues(
|
||||||
|
TEMPLATE_SERVER_ERROR);
|
||||||
|
trv.put(BODY_ERROR_MESSAGE, "Internal server error:<br /> " + e);
|
||||||
|
return trv;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We processed a response, and want to show a template.
|
* We processed a response, and want to show a template.
|
||||||
* Version for JSP page.
|
* Version for JSP page.
|
||||||
|
|
Loading…
Add table
Reference in a new issue