소스 검색

更新

master
牧羊人 4 년 전
부모
커밋
b325de0da6
2개의 변경된 파일40개의 추가작업 그리고 2개의 파일을 삭제
  1. +39
    -0
      src/main/java/com/taauav/common/util/ShiroUtils.java
  2. +1
    -2
      src/main/java/com/taauav/front/service/impl/UserAdminServiceImpl.java

+ 39
- 0
src/main/java/com/taauav/common/util/ShiroUtils.java 파일 보기

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

+ 1
- 2
src/main/java/com/taauav/front/service/impl/UserAdminServiceImpl.java 파일 보기

@@ -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("设置成功");
}
}

Loading…
취소
저장