((LogoutAware) authc).onLogout((SimplePrincipalCollection) attribute); | ((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); | |||||
} | |||||
} | } |
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
import com.taauav.admin.constant.CommonConstant; | import com.taauav.admin.constant.CommonConstant; | ||||
import com.taauav.admin.dto.TauvDriverDTO; | import com.taauav.admin.dto.TauvDriverDTO; | ||||
import com.taauav.admin.entity.SysAdmin; | |||||
import com.taauav.admin.entity.SysCity; | import com.taauav.admin.entity.SysCity; | ||||
import com.taauav.admin.mapper.TauvInspectFileMapper; | import com.taauav.admin.mapper.TauvInspectFileMapper; | ||||
import com.taauav.admin.service.ISysCityService; | import com.taauav.admin.service.ISysCityService; | ||||
//重置对应用户的权限 | //重置对应用户的权限 | ||||
UserAdminVo adminInfo = getAdminInfo(adminId); | UserAdminVo adminInfo = getAdminInfo(adminId); | ||||
String username = adminInfo.getUsername(); | String username = adminInfo.getUsername(); | ||||
ShiroUtils.deleteCache(username, false); | |||||
ShiroUtils.deleteCacheEx(username, false); | |||||
return response.success("设置成功"); | return response.success("设置成功"); | ||||
} | } | ||||
} | } |