示例#1
0
  /**
   * Verify that the user is trying to log in with the method of account creation
   *
   * @param candidate - user who is trying to log in
   * @param OAuthService - string representation of the method of login
   * @return true if the method of login is the same with the method of creation
   */
  public boolean matchOAuthLoginMethod(Candidate candidate, String OAuthService) {
    if (!candidate.getExternal_Auth_ID().equals(OAuthService)) {
      // the candidate should be informed that this method of login is not correct
      // setting message with FacesContext fails here, because currentInstance is null

      LabelController lblController = new LabelController();
      if (candidate.getExternal_Auth_ID().equals("SIMPLE"))
        setErrorMsg(lblController.getoAuthLoginWithUsernamePassword());
      if (candidate.getExternal_Auth_ID().equals("FACEBOOK"))
        setErrorMsg(lblController.getoAuthLoginWithFacebook());
      if (candidate.getExternal_Auth_ID().equals("LINKEDIN"))
        setErrorMsg(lblController.getoAuthLoginWithLinkedin());
      if (candidate.getExternal_Auth_ID().equals("GOOGLE-PLUS"))
        setErrorMsg(lblController.getoAuthLoginWithGoogle());

      return false;
    }

    return true;
  }