@ Nonnull public final EContinue checkUserAndShowLogin ( @ Nonnull final IRequestWebScopeWithoutResponse aRequestScope , @ Nonnull final UnifiedResponse aUnifiedResponse ) { final LoggedInUserManager aLoggedInUserManager = LoggedInUserManager . getInstance ( ) ; String sSessionUserID = aLoggedInUserManager . getCurrentUserID ( ) ; boolean bLoggedInInThisRequest = false ; if ( sSessionUserID == null ) { // No user currently logged in -> start login boolean bLoginError = false ; ICredentialValidationResult aLoginResult = ELoginResult . SUCCESS ; // Is the special login-check action present? if ( isLoginInProgress ( aRequestScope ) ) { // Login screen was already shown // -> Check request parameters final String sLoginName = getLoginName ( aRequestScope ) ; final String sPassword = getPassword ( aRequestScope ) ; // Resolve user - may be null final IUser aUser = getUserOfLoginName ( sLoginName ) ; // Try main login aLoginResult = aLoggedInUserManager . loginUser ( aUser , sPassword , m_aRequiredRoleIDs ) ; if ( aLoginResult . isSuccess ( ) ) { // Credentials are valid - implies that the user was resolved // correctly sSessionUserID = aUser . getID ( ) ; bLoggedInInThisRequest = true ; } else { // Credentials are invalid if ( GlobalDebug . isDebugMode ( ) ) LOGGER . warn ( "Login of '" + sLoginName + "' failed because " + aLoginResult ) ; // Anyway show the error message only if at least some credential // values are passed bLoginError = StringHelper . hasText ( sLoginName ) || StringHelper . hasText ( sPassword ) ; } } if ( sSessionUserID == null ) { // Show login screen as no user is in the session final IHTMLProvider aLoginScreenProvider = createLoginScreen ( bLoginError , aLoginResult ) ; PhotonHTMLHelper . createHTMLResponse ( aRequestScope , aUnifiedResponse , aLoginScreenProvider ) ; } } // Update details final LoginInfo aLoginInfo = aLoggedInUserManager . getLoginInfo ( sSessionUserID ) ; if ( aLoginInfo != null ) { // Update last login info aLoginInfo . setLastAccessDTNow ( ) ; // Set custom attributes modifyLoginInfo ( aLoginInfo , aRequestScope , bLoggedInInThisRequest ) ; } else { // Internal inconsistency if ( sSessionUserID != null ) LOGGER . error ( "Failed to resolve LoginInfo of user ID '" + sSessionUserID + "'" ) ; } if ( bLoggedInInThisRequest ) { // Avoid double submit by simply redirecting to the desired destination // URL without the login parameters aUnifiedResponse . setRedirect ( aRequestScope . getURL ( ) ) ; return EContinue . BREAK ; } // Continue only, if a valid user ID is present return EContinue . valueOf ( sSessionUserID != null ) ; }
Main login routine .