Commit caf6edcd by 吴迪

【新增】修改登录

parent 3334283f
...@@ -21,6 +21,7 @@ import org.apache.shiro.subject.PrincipalCollection; ...@@ -21,6 +21,7 @@ import org.apache.shiro.subject.PrincipalCollection;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
/** /**
...@@ -44,14 +45,20 @@ public class OAuth2Realm extends AuthorizingRealm { ...@@ -44,14 +45,20 @@ public class OAuth2Realm extends AuthorizingRealm {
*/ */
@Override @Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
SysUserEntity user = (SysUserEntity)principals.getPrimaryPrincipal(); Object object = principals.getPrimaryPrincipal();
Long userId = user.getUserId(); SimpleAuthorizationInfo info =null;
if(object instanceof SysUserEntity) {
SysUserEntity user = (SysUserEntity)principals.getPrimaryPrincipal();
Long userId = user.getUserId();
//用户权限列表 //用户权限列表
Set<String> permsSet = shiroService.getUserPermissions(userId); Set<String> permsSet = shiroService.getUserPermissions(userId);
info = new SimpleAuthorizationInfo();
info.setStringPermissions(permsSet);
} else{
}
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
info.setStringPermissions(permsSet);
return info; return info;
} }
...@@ -74,14 +81,14 @@ public class OAuth2Realm extends AuthorizingRealm { ...@@ -74,14 +81,14 @@ public class OAuth2Realm extends AuthorizingRealm {
if(accessToken.startsWith("qianduan_")) { if(accessToken.startsWith("qianduan_")) {
//todo //todo
MemberEntity memberEntity = memberDao.selectById(tokenEntity.getUserId()); MemberEntity memberEntity = memberDao.selectById(tokenEntity.getUserId());
new SimpleAuthenticationInfo(memberEntity, accessToken, getName()); info = new SimpleAuthenticationInfo(memberEntity, accessToken, getName());
} else { } else {
user = shiroService.queryUser(tokenEntity.getUserId()); user = shiroService.queryUser(tokenEntity.getUserId());
//账号锁定 //账号锁定
if(user.getStatus() == 0){ if(user.getStatus() == 0){
throw new LockedAccountException("账号已被锁定,请联系管理员"); throw new LockedAccountException("账号已被锁定,请联系管理员");
} }
new SimpleAuthenticationInfo(user, accessToken, getName()); info = new SimpleAuthenticationInfo(user, accessToken, getName());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment