diff options
| author | 段冬梅 <[email protected]> | 2018-12-15 11:42:57 +0800 |
|---|---|---|
| committer | 段冬梅 <[email protected]> | 2018-12-15 11:42:57 +0800 |
| commit | a3333c5c080562b3ed7bce9782e723126974121a (patch) | |
| tree | 8938066c587ea0254de050fa80e2a3c83c4a31d9 | |
| parent | 3371f95f70d66b30efba7820622935c55600e5c4 (diff) | |
无变化
| -rw-r--r-- | src/main/java/com/nis/web/controller/sys/UserController.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main/java/com/nis/web/controller/sys/UserController.java b/src/main/java/com/nis/web/controller/sys/UserController.java index 27e4a68..c904daa 100644 --- a/src/main/java/com/nis/web/controller/sys/UserController.java +++ b/src/main/java/com/nis/web/controller/sys/UserController.java @@ -20,6 +20,7 @@ import org.apache.shiro.session.Session; import org.apache.shiro.subject.PrincipalCollection; import org.apache.shiro.subject.SimplePrincipalCollection; import org.apache.shiro.subject.support.DefaultSubjectContext; +import org.crazycake.shiro.RedisCache; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; @@ -293,6 +294,19 @@ public class UserController extends BaseController{ if (StringUtils.validatePassword(oldPassword, user.getPassword())){ userService.updatePasswordById(user.getId(), user.getLoginId(), newPassword); + 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()); + } model.addAttribute("message", "update_success"); }else{ model.addAttribute("message", "update_failed"); |
