|
|
@@ -3,6 +3,7 @@ package com.jzg.config;
|
|
|
import com.jzg.entity.RedisToken;
|
|
|
import com.jzg.entity.SysUserRole;
|
|
|
import com.jzg.entity.SysUser;
|
|
|
+import com.jzg.exception.SystemException;
|
|
|
import com.jzg.service.SysUserRoleService;
|
|
|
import com.jzg.service.SysUserService;
|
|
|
import com.jzg.util.PasswordUtils;
|
|
|
@@ -38,6 +39,7 @@ public class JzgAuthenticationProvider implements AuthenticationProvider {
|
|
|
String username = authentication.getName();
|
|
|
String rawPassword = (String) authentication.getCredentials();
|
|
|
Object details = authentication.getDetails();
|
|
|
+ String system = ((JzgUsernamePasswordAuthenticationToken)authentication).getSystem();
|
|
|
|
|
|
SysUser byId = sysUserService.getById(username);
|
|
|
String salt = byId.getSalt();
|
|
|
@@ -47,13 +49,13 @@ public class JzgAuthenticationProvider implements AuthenticationProvider {
|
|
|
|
|
|
// 对比密码
|
|
|
if (!encryptedPassword.equals(byId.getPassword())) {
|
|
|
- throw new BadCredentialsException("Invalid username or password");
|
|
|
+ throw new SystemException("用户名或密码错误");
|
|
|
}
|
|
|
//获取角色组
|
|
|
List<SysUserRole> userRoles = sysUserRoleService.getUserRole(username);
|
|
|
|
|
|
List<JzgGrantedAuthority> authorities = userRoles.stream()
|
|
|
- .map(role -> new JzgGrantedAuthority("JZG",role.getRoleId()))
|
|
|
+ .map(role -> new JzgGrantedAuthority(system,role.getRoleId()))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
return new UsernamePasswordAuthenticationToken(username, rawPassword, authorities);
|