|
@@ -37,16 +37,19 @@ public class AuthenticationController {
|
|
|
|
|
|
|
|
@PostMapping("/login")
|
|
@PostMapping("/login")
|
|
|
public String loginByUserPwd(String username, String password, Integer expiration) {
|
|
public String loginByUserPwd(String username, String password, Integer expiration) {
|
|
|
|
|
+// Authentication authentication = authenticate(username, password);
|
|
|
|
|
+// JwtUser jwtUser = (JwtUser) authentication.getPrincipal();
|
|
|
|
|
+// LocalDate start = Convert.convert(LocalDate.class, "2021-6-2");
|
|
|
|
|
+// if (authentication.getAuthorities()
|
|
|
|
|
+// .contains(new SimpleGrantedAuthority(AuthorityName.ROLE_ADMIN.name()))) {
|
|
|
|
|
+// return jwtTokenUtil.generateToken(jwtUser);
|
|
|
|
|
+// } else if (LocalDate.now().isAfter(start)) {
|
|
|
|
|
+// return jwtTokenUtil.generateToken(jwtUser);
|
|
|
|
|
+// }
|
|
|
|
|
+// throw new AuthenticationException("禁止登录", null);
|
|
|
Authentication authentication = authenticate(username, password);
|
|
Authentication authentication = authenticate(username, password);
|
|
|
JwtUser jwtUser = (JwtUser) authentication.getPrincipal();
|
|
JwtUser jwtUser = (JwtUser) authentication.getPrincipal();
|
|
|
- LocalDate start = Convert.convert(LocalDate.class, "2021-6-2");
|
|
|
|
|
- if (authentication.getAuthorities()
|
|
|
|
|
- .contains(new SimpleGrantedAuthority(AuthorityName.ROLE_ADMIN.name()))) {
|
|
|
|
|
- return jwtTokenUtil.generateToken(jwtUser);
|
|
|
|
|
- } else if (LocalDate.now().isAfter(start)) {
|
|
|
|
|
- return jwtTokenUtil.generateToken(jwtUser);
|
|
|
|
|
- }
|
|
|
|
|
- throw new AuthenticationException("禁止登录", null);
|
|
|
|
|
|
|
+ return jwtTokenUtil.generateToken(jwtUser);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|