Example #1
0
 /** Resets the login screen back to its initial state. */
 public void reset() {
   UserSessionManager.getUserSessionManager().logout();
   user = null;
   Object landingScreen = ui.loadComponentFromFile(XML_LOGIN, this);
   Object usernameField = ui.find(landingScreen, "usernameField");
   ui.removeAll(mainPanel);
   ui.add(mainPanel, landingScreen);
   ui.setFocus(usernameField);
 }
Example #2
0
 /** The callback method for when a user preses a login button in this screen. */
 public void attemptLogin() {
   Object usernameField = ui.find(mainPanel, "usernameField");
   Object passwordField = ui.find(mainPanel, "passwordField");
   String username = ui.getText(usernameField);
   String password = ui.getText(passwordField);
   UserSessionManager manager = UserSessionManager.getUserSessionManager();
   AuthenticationResult result = manager.login(username, password);
   if (result == AuthenticationResult.NOSUCHUSER || result == AuthenticationResult.WRONGPASSWORD) {
     displayWarningMessage(INCORRECT_LOGIN_MESSAGE);
   }
   if (result == AuthenticationResult.SUCCESS) {
     user = manager.getCurrentUser();
     if (user.needsNewPassword()) {
       changeModeNewPassword();
     } else if (numberOfSecurityQuestions(user) < settings.getRequiredQuestionsRange().value()) {
       changeModeNewQuestions();
     } else {
       changeModePatientView();
     }
   }
 }