Exemplo n.º 1
0
  @Override
  public ResponseVO isUserAuthenticated(String authString, ResponseVO response) throws IOException {
    String decodedAuth = "";
    // Header is in the format "Basic 5tyc0uiDat4"
    // We need to extract data before decoding it back to original string
    // Decode the data back to original string
    byte[] bytes = null;
    new Base64();
    bytes = Base64.decode(authString);
    decodedAuth = new String(bytes);

    String[] decodedAuths = decodedAuth.split(":");

    User user = getUserDetail(decodedAuths[0], decodedAuths[1]);
    if (user == null) {
      response.setSuccess(false);
      response.setError(new Error(222, "Invalid credentials!!"));
    } else {
      String accessToken = ApplicationUtilities.generateAccessToken(user);
      CachedObject newCachedObject = new CachedObject(user.getUuid(), accessToken, 0);
      CacheManager.putCache(newCachedObject);
      response.setSuccess(true);
      // response.setData(new LoggedInUserVO(accessToken,user.getEmailAddress()));
    }
    return response;
  }
Exemplo n.º 2
0
 @Override
 public ResponseVO isUserAuthenticated(DoLoginVo doLoginVo, ResponseVO response) {
   User user = getUserDetail(doLoginVo.getAuthString());
   List<AssignedTest> assignedTests = null;
   if (user != null) {
     UserProfile profile = getUserProfileByUUID(user.getUuid());
     if (profile != null) {
       profile.setMobileNumber(user.getMobileNumber());
       profile.setEmailAddress(user.getEmailAddress());
       profile.setUsername(user.getUsername());
       assignedTests = schoolAssesmentService.findAllAssignedTestByuser(user);
     }
     String accessToken = ApplicationUtilities.generateAccessToken(user);
     user.setAccessToken(accessToken);
     saveUser(user);
     response.setData(new LoggedInUserVO(accessToken, profile, assignedTests));
   } else {
     response.setData("Invalid Student code!!");
   }
   response.setSuccess(true);
   return response;
 }