parent
b7120acfad
commit
bfb333d57f
|
@ -18,15 +18,12 @@ public class UserController {
|
||||||
|
|
||||||
@RequestMapping("/login")
|
@RequestMapping("/login")
|
||||||
public boolean login(@RequestBody User user) {
|
public boolean login(@RequestBody User user) {
|
||||||
if(user.getUserName().equals("user") && user.getPassword().equals("password")) {
|
return user.getUserName().equals("user") && user.getPassword().equals("password");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/user")
|
@RequestMapping("/user")
|
||||||
public Principal user(HttpServletRequest request) {
|
public Principal user(HttpServletRequest request) {
|
||||||
String authToken = request.getHeader("Authorization").substring("Basic".length()).trim();
|
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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue