import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import org.mxchange.jjobs.beans.BaseJobsController;
+import org.mxchange.jjobs.beans.user.JobsUserWebSessionController;
import org.mxchange.jusercore.container.login.LoginContainer;
import org.mxchange.jusercore.container.login.UserLoginContainer;
import org.mxchange.jusercore.events.login.UserLoggedInEvent;
import org.mxchange.jusercore.model.user.UserUtils;
import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
-import org.mxchange.jjobs.beans.user.JobsUserWebSessionController;
/**
* A web bean for user registration
*/
@Named ("loginController")
@SessionScoped
-public class JobsUserLoginWebSessionBean implements JobsUserLoginWebSessionController {
+public class JobsUserLoginWebSessionBean extends BaseJobsController implements JobsUserLoginWebSessionController {
+
+ /**
+ * Path name for guest base template
+ */
+ private static final String GUEST_BASE_TEMPLATE_NAME = "guest/guest"; //NOI18N
+
+ /**
+ * Path name for logged-in user base template
+ */
+ private static final String USER_BASE_TEMPLATE_NAME = "login/user/user"; //NOI18N
/**
* Serial number
Context context = new InitialContext();
// Try to lookup
- this.loginBean = (UserLoginSessionBeanRemote) context.lookup("ejb/stateless-jjobs-login"); //NOI18N
+ this.loginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/jjobs-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N
} catch (final NamingException ex) {
// Continue to throw
throw new FaceletException(ex);
@Override
public String doLogin () {
// Get user instance
- User user = this.userController.createUserInstance();
+ User user = this.userController.createUserLogin();
// Create login container
LoginContainer container = new UserLoginContainer(user, this.userController.getUserPassword());
// All fine
return "login"; //NOI18N
- } catch (final UserNotFoundException | UserStatusLockedException | UserStatusUnconfirmedException | UserPasswordMismatchException ex) {
- // Throw again
- throw new FaceletException(ex);
+ } catch (final UserNotFoundException | UserStatusLockedException | UserStatusUnconfirmedException ex) {
+ // Show JSF message
+ this.showFacesMessage("form_user_login:userName", ex); //NOI18N
+ return ""; //NOI18N
+ } catch (final UserPasswordMismatchException ex) {
+ // Show JSF message
+ this.showFacesMessage("form_user_login:userPassword", ex); //NOI18N
+ return ""; //NOI18N
}
}
@Override
public String getCurrentPassword () {
- return currentPassword;
+ return this.currentPassword;
}
@Override
}
@Override
- public boolean isGuest () {
- return (!this.isUserLoggedIn());
+ public boolean ifUserMustChangePassword () {
+ return (this.isUserLoggedIn() && this.getLoggedInUser().getUserMustChangePassword());
}
@Override
// Trace message
// NOISY-DEBUG System.out.println(MessageFormat.format("JobsUserLoginWebSessionBean:isUserLoggedIn: this.userLoggedIn={0} - EXIT!", this.userLoggedIn));
+
// Return it
return this.userLoggedIn;
}
+
}