BAEL - 1916 (#4729)

Code refactored
This commit is contained in:
Tino Mulanchira Thomas 2018-07-16 21:26:50 +03:00 committed by maibin
parent b7120acfad
commit bfb333d57f
1 changed files with 3 additions and 6 deletions

View File

@ -18,15 +18,12 @@ public class UserController {
@RequestMapping("/login")
public boolean login(@RequestBody User user) {
if(user.getUserName().equals("user") && user.getPassword().equals("password")) {
return true;
}
return false;
return user.getUserName().equals("user") && user.getPassword().equals("password");
}
@RequestMapping("/user")
public Principal user(HttpServletRequest request) {
String authToken = request.getHeader("Authorization").substring("Basic".length()).trim();
return () -> new String(Base64.getDecoder().decode(authToken)).split(":")[0];
return () -> new String(Base64.getDecoder().decode(authToken)).split(":")[0];
}
}