use of com.helger.photon.security.login.ELoginResult 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)));
}
}
use of com.helger.photon.security.login.ELoginResult in project phoss-smp by phax.
the class AjaxExecutorPublicLogin method mainHandleRequest.
@Override
protected void mainHandleRequest(@Nonnull final LayoutExecutionContext aLEC, @Nonnull final PhotonUnifiedResponse aAjaxResponse) throws Exception {
final String sLoginName = aLEC.params().getAsString(CLogin.REQUEST_ATTR_USERID);
final String sPassword = aLEC.params().getAsString(CLogin.REQUEST_ATTR_PASSWORD);
// Main login
final ELoginResult eLoginResult = LoggedInUserManager.getInstance().loginUser(sLoginName, sPassword, CSMP.REQUIRED_ROLE_IDS_WRITABLERESTAPI);
if (eLoginResult.isSuccess()) {
aAjaxResponse.json(new JsonObject().add(JSON_LOGGEDIN, true));
return;
}
// Get the rendered content of the menu area
if (GlobalDebug.isDebugMode())
if (LOGGER.isWarnEnabled())
LOGGER.warn("Login of '" + sLoginName + "' failed because " + eLoginResult);
final Locale aDisplayLocale = aLEC.getDisplayLocale();
final IHCNode aRoot = error(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