@@ -110,4 +110,43 @@ public class ShiroUtils { | |||
((LogoutAware) authc).onLogout((SimplePrincipalCollection) attribute); | |||
} | |||
/** | |||
* 删除用户缓存信息 | |||
* | |||
* @param username | |||
* @param isRemoveSession | |||
*/ | |||
public static void deleteCacheEx(String username, boolean isRemoveSession) { | |||
Session session = null; | |||
Collection<Session> sessions = redisSessionDAO.getActiveSessions(); | |||
UserAdmin userAdmin; | |||
Object attribute = null; | |||
for (Session sessionInfo : sessions) { | |||
log.warn("attribute=" + DefaultSubjectContext.PRINCIPALS_SESSION_KEY); | |||
attribute = sessionInfo.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY); | |||
if (null == attribute) { | |||
continue; | |||
} | |||
userAdmin = (UserAdmin) ((SimplePrincipalCollection) attribute).getPrimaryPrincipal(); | |||
if (null == userAdmin) { | |||
continue; | |||
} | |||
if (Objects.equals(userAdmin.getUsername(), username)) { | |||
session = sessionInfo; | |||
break; | |||
} | |||
} | |||
if (null == session || null == attribute) { | |||
return; | |||
} | |||
//删除session | |||
if (isRemoveSession) { | |||
redisSessionDAO.delete(session); | |||
} | |||
//删除cache,在访问受限接口时会重新授权 | |||
DefaultWebSecurityManager securityManager = (DefaultWebSecurityManager) SecurityUtils.getSecurityManager(); | |||
Authenticator authc = securityManager.getAuthenticator(); | |||
((LogoutAware) authc).onLogout((SimplePrincipalCollection) attribute); | |||
} | |||
} |
@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.taauav.admin.constant.CommonConstant; | |||
import com.taauav.admin.dto.TauvDriverDTO; | |||
import com.taauav.admin.entity.SysAdmin; | |||
import com.taauav.admin.entity.SysCity; | |||
import com.taauav.admin.mapper.TauvInspectFileMapper; | |||
import com.taauav.admin.service.ISysCityService; | |||
@@ -838,7 +837,7 @@ public class UserAdminServiceImpl extends BaseServiceImpl<UserAdminMapper, UserA | |||
//重置对应用户的权限 | |||
UserAdminVo adminInfo = getAdminInfo(adminId); | |||
String username = adminInfo.getUsername(); | |||
ShiroUtils.deleteCache(username, false); | |||
ShiroUtils.deleteCacheEx(username, false); | |||
return response.success("设置成功"); | |||
} | |||
} |