修复拥有用户管理权限的用户,修改其他用户密码后不生效问题。
This commit is contained in:
@@ -110,6 +110,20 @@ public class UserController extends BaseController{
|
||||
// 如果新密码为空,则不更换密码
|
||||
if (StringUtils.isNotBlank(user.getNewPassword())) {
|
||||
user.setPassword(StringUtils.entryptPassword(user.getNewPassword()));
|
||||
|
||||
//密码修改之后,更新此用户的redis缓存
|
||||
RealmSecurityManager securityManager = (RealmSecurityManager) SecurityUtils.getSecurityManager();
|
||||
Collection<Realm> realm = securityManager.getRealms();
|
||||
for (Realm realm2 : realm) {
|
||||
SystemAuthorizingRealm userRealm = (SystemAuthorizingRealm) realm2;
|
||||
RedisCache<Object, AuthenticationInfo> cache = (RedisCache<Object, AuthenticationInfo>) userRealm.getAuthenticationCache();
|
||||
String keyPrefix = cache.getKeyPrefix();
|
||||
for (AuthenticationInfo auth : cache.values()) {
|
||||
userRealm.getAuthenticationCache().remove(auth.getPrincipals().getPrimaryPrincipal());
|
||||
}
|
||||
systemService.deleteAuthenticationCache(keyPrefix + user.getName());
|
||||
systemService.deleteAuthenticationCache(keyPrefix + user.getId());
|
||||
}
|
||||
}
|
||||
/*if (!beanValidator(model, user)){
|
||||
return form(user, model);
|
||||
|
||||
Reference in New Issue
Block a user