Commit caf6edcd by 吴迪

【新增】修改登录

parent 3334283f
......@@ -21,6 +21,7 @@ import org.apache.shiro.subject.PrincipalCollection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashSet;
import java.util.Set;
/**
......@@ -44,14 +45,20 @@ public class OAuth2Realm extends AuthorizingRealm {
*/
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
SysUserEntity user = (SysUserEntity)principals.getPrimaryPrincipal();
Long userId = user.getUserId();
Object object = principals.getPrimaryPrincipal();
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;
}
......@@ -74,14 +81,14 @@ public class OAuth2Realm extends AuthorizingRealm {
if(accessToken.startsWith("qianduan_")) {
//todo
MemberEntity memberEntity = memberDao.selectById(tokenEntity.getUserId());
new SimpleAuthenticationInfo(memberEntity, accessToken, getName());
info = new SimpleAuthenticationInfo(memberEntity, accessToken, getName());
} else {
user = shiroService.queryUser(tokenEntity.getUserId());
//账号锁定
if(user.getStatus() == 0){
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