Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Object handleAccess(Request request, Response response){
- String decoded = Base64.getDecoder().decode(request.params(":Authorization")).toString();
- String userName = decoded.split(":")[0];
- String userPassword = decoded.split(":")[0];
- List<Users> matchingUsers = usersRepository.getUserUsingNameAndPassword(userName, userPassword);
- if(!(matchingUsers.isEmpty())){
- response.status(UNSUCCESSFULLOGIN);
- throw new UserDoesNotExist("User with name: " + userName + " does not exist");
- }
- else{
- SessionData sessionData = new SessionData(null, matchingUsers.get(0).getId(), new Date().toString());
- return sessionDataRepostiory.insertSession(sessionData).getSessionId();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement