/**
   * Check if the user exists if user exists check if profile is verified If there is no entry in
   * user profile table make an entry and return isVerified as false; else if profile is verified,
   * return isVerified as true if profile is not verified, return isVerified as false; if user does
   * not exists return exists as not exists; if user/pwd combo is incorrect return exists as
   * incorrect pwd.
   *
   * @param authRequest
   * @return
   */
  @RequestMapping(
      value = "/signin",
      method = RequestMethod.POST,
      consumes = MediaType.APPLICATION_JSON_VALUE)
  @ResponseBody
  public AuthResponse authenticate(@RequestBody AuthRequest authRequest) {

    AuthResponse authResponse = new AuthResponse();
    authResponse.setUserId(authRequest.getEmail());
    UserAuth userAuth =
        authHelper.adUserExists(
            authRequest.getEmail(), authRequest.getPwd(), authRequest.getSourceChannel());
    if (userAuth.equals(UserAuth.EXISTS)) {
      authResponse.setStatus(userAuth.getUserAuth());
      UserProfile userProfile = authHelper.getUserProfile(authRequest);
      if (userProfile == null) {
        authResponse.setVerified(VerificationStatus.NOT_VERIFIED.getVerified());
      } else {
        authResponse = authTransformer.transform(userProfile, authResponse);
      }
    } else if (userAuth.equals(UserAuth.NOT_EXISTS) || userAuth.equals(UserAuth.INCORRECT_PWD)) {
      authResponse.setStatus(userAuth.getUserAuth());
      authResponse.setVerified(VerificationStatus.NOT_VERIFIED.getVerified());
    }

    return authResponse;
  }
 /**
  * For sign up using FB/GOOG- the signin service should be called. For sign up using custom -
  * insert data into ADUser table and proceed. set verified as false.
  *
  * <p>If the email already exists - send the status as 1, For newly added send it as 4.
  *
  * @param signUpRequest
  * @return
  */
 @RequestMapping(
     value = "/signup",
     method = RequestMethod.POST,
     consumes = MediaType.APPLICATION_JSON_VALUE)
 @ResponseBody
 public AuthResponse registerUser(@RequestBody SignUpRequest signUpRequest) {
   AuthResponse authResponse = new AuthResponse();
   authResponse.setUserId(signUpRequest.getEmail());
   UserAuth userAuth =
       authHelper.saveADUserNotExistsCustom(signUpRequest.getEmail(), signUpRequest.getPassword());
   authResponse.setStatus(userAuth.getUserAuth());
   authResponse.setVerified(
       VerificationStatus.NOT_VERIFIED
           .getVerified()); // Return false if the profile details is yet to be completed.
   return authResponse;
 }