mirror of
https://gitee.com/gz-yami/mall4j.git
synced 2026-03-22 09:17:16 +08:00
优化登录接口
This commit is contained in:
@@ -41,20 +41,7 @@ public class AdminAuthenticationProvider extends AbstractUserDetailsAuthenticati
|
||||
|
||||
@Override
|
||||
protected UserDetails retrieveUser(String username, Authentication authentication) throws BaseYamiAuth2Exception {
|
||||
UserDetails user;
|
||||
try {
|
||||
user = yamiUserDetailsService.loadUserByUsername(username);
|
||||
} catch (UsernameNotFoundExceptionBase var6) {
|
||||
throw new UsernameNotFoundExceptionBase("账号或密码不正确");
|
||||
}
|
||||
if (!user.isEnabled()) {
|
||||
throw new UsernameNotFoundExceptionBase("账号已被锁定,请联系管理员");
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void additionalAuthenticationChecks(UserDetails sysUser, Authentication authentication) throws BaseYamiAuth2Exception {
|
||||
AdminAuthenticationToken adminAuthenticationToken = (AdminAuthenticationToken) authentication;
|
||||
|
||||
String kaptchaKey = SecurityConstants.SPRING_SECURITY_RESTFUL_IMAGE_CODE + adminAuthenticationToken.getSessionUUID();
|
||||
@@ -67,17 +54,28 @@ public class AdminAuthenticationProvider extends AbstractUserDetailsAuthenticati
|
||||
throw new ImageCodeNotMatchExceptionBase("验证码有误");
|
||||
}
|
||||
|
||||
UserDetails user;
|
||||
try {
|
||||
user = yamiUserDetailsService.loadUserByUsername(username);
|
||||
} catch (UsernameNotFoundExceptionBase var6) {
|
||||
throw new UsernameNotFoundExceptionBase("账号或密码不正确");
|
||||
}
|
||||
|
||||
|
||||
String encodedPassword = sysUser.getPassword();
|
||||
String encodedPassword = user.getPassword();
|
||||
String rawPassword = authentication.getCredentials().toString();
|
||||
|
||||
// 密码不正确
|
||||
if (!passwordEncoder.matches(rawPassword,encodedPassword)){
|
||||
throw new BadCredentialsExceptionBase("账号或密码不正确");
|
||||
}
|
||||
|
||||
if (!user.isEnabled()) {
|
||||
throw new UsernameNotFoundExceptionBase("账号已被锁定,请联系管理员");
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Authentication createSuccessAuthentication(Authentication authentication, UserDetails user) {
|
||||
AdminAuthenticationToken result = new AdminAuthenticationToken(user, authentication.getCredentials());
|
||||
|
||||
@@ -41,11 +41,6 @@ public class MiniAppAuthenticationProvider extends AbstractUserDetailsAuthentica
|
||||
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
@Override
|
||||
protected void additionalAuthenticationChecks(UserDetails var1, Authentication authentication) throws AuthenticationException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Authentication createSuccessAuthentication(Authentication authentication, UserDetails user) {
|
||||
MiniAppAuthenticationToken result = new MiniAppAuthenticationToken(user, authentication.getCredentials());
|
||||
|
||||
@@ -28,8 +28,6 @@ public abstract class AbstractUserDetailsAuthenticationProvider implements Authe
|
||||
|
||||
|
||||
|
||||
protected abstract void additionalAuthenticationChecks(UserDetails var1, Authentication var2) throws AuthenticationException;
|
||||
|
||||
@Override
|
||||
public final void afterPropertiesSet() {
|
||||
}
|
||||
@@ -47,8 +45,6 @@ public abstract class AbstractUserDetailsAuthenticationProvider implements Authe
|
||||
throw var6;
|
||||
}
|
||||
|
||||
this.additionalAuthenticationChecks(user, authentication);
|
||||
|
||||
return this.createSuccessAuthentication(authentication, user);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,10 +45,6 @@ public class MpAuthenticationProvider extends AbstractUserDetailsAuthenticationP
|
||||
private final WxMpService wxMpService;
|
||||
|
||||
|
||||
@Override
|
||||
protected void additionalAuthenticationChecks(UserDetails var1, Authentication authentication) throws AuthenticationException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Authentication createSuccessAuthentication(Authentication authentication, UserDetails user) {
|
||||
|
||||
Reference in New Issue
Block a user