修复拥有用户管理权限的用户,修改其他用户密码后不生效问题。

(cherry picked from commit fa42935d46)
This commit is contained in:
duandongmei
2019-01-23 04:40:05 +00:00
committed by 王鑫
parent da24fa3b84
commit 1346fd1bfc

View File

@@ -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);