use of com.helger.photon.bootstrap4.alert.BootstrapErrorBox in project phoss-directory by phax.
the class AjaxExecutorPublicLogin method handleRequest.
public void handleRequest(@Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final PhotonUnifiedResponse aAjaxResponse) throws Exception {
final LayoutExecutionContext aLEC = LayoutExecutionContext.createForAjaxOrAction(aRequestScope);
final String sLoginName = aRequestScope.params().getAsString(CLogin.REQUEST_ATTR_USERID);
final String sPassword = aRequestScope.params().getAsString(CLogin.REQUEST_ATTR_PASSWORD);
// Main login
final ELoginResult eLoginResult = LoggedInUserManager.getInstance().loginUser(sLoginName, sPassword, AppSecurity.REQUIRED_ROLE_IDS_VIEW);
if (eLoginResult.isSuccess()) {
aAjaxResponse.json(new JsonObject().add(JSON_LOGGEDIN, true));
} else {
// Get the rendered content of the menu area
if (GlobalDebug.isDebugMode())
LOGGER.warn("Login of '" + sLoginName + "' failed because " + eLoginResult);
final Locale aDisplayLocale = aLEC.getDisplayLocale();
final IHCNode aRoot = new BootstrapErrorBox().addChild(EPhotonCoreText.LOGIN_ERROR_MSG.getDisplayText(aDisplayLocale) + " " + eLoginResult.getDisplayText(aDisplayLocale));
// Set as result property
aAjaxResponse.json(new JsonObject().add(JSON_LOGGEDIN, false).add(JSON_HTML, HCRenderer.getAsHTMLStringWithoutNamespaces(aRoot)));
}
}
Aggregations