Advertisement
Coriic

Untitled

Jan 18th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. public Object handleAccess(Request request, Response response){
  2.         String decoded = Base64.getDecoder().decode(request.params(":Authorization")).toString();
  3.         String userName = decoded.split(":")[0];
  4.         String userPassword = decoded.split(":")[0];
  5.         List<Users> matchingUsers = usersRepository.getUserUsingNameAndPassword(userName, userPassword);
  6.         if(!(matchingUsers.isEmpty())){
  7.             response.status(UNSUCCESSFULLOGIN);
  8.             throw new UserDoesNotExist("User with name: " + userName + " does not exist");
  9.         }
  10.         else{
  11.             SessionData sessionData = new SessionData(null, matchingUsers.get(0).getId(), new Date().toString());
  12.             return sessionDataRepostiory.insertSession(sessionData).getSessionId();
  13.         }
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement