Commit 3334283f by 唐功亮

【修改】 OAuth2Realm.java

parent 034976e1
...@@ -287,15 +287,12 @@ ...@@ -287,15 +287,12 @@
<dependency> <dependency>
<groupId>net.sf.barcode4j</groupId> <groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j</artifactId> <artifactId>barcode4j</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.2.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.sf.barcode4j</groupId> <groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j-light</artifactId> <artifactId>barcode4j-light</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.2.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.sf.barcode4j</groupId> <groupId>net.sf.barcode4j</groupId>
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
package io.office.modules.sys.oauth2; package io.office.modules.sys.oauth2;
import io.office.modules.manage.dao.MemberDao;
import io.office.modules.manage.entity.MemberEntity;
import io.office.modules.sys.entity.SysUserEntity; import io.office.modules.sys.entity.SysUserEntity;
import io.office.modules.sys.entity.SysUserTokenEntity; import io.office.modules.sys.entity.SysUserTokenEntity;
import io.office.modules.sys.service.ShiroService; import io.office.modules.sys.service.ShiroService;
...@@ -30,7 +32,8 @@ import java.util.Set; ...@@ -30,7 +32,8 @@ import java.util.Set;
public class OAuth2Realm extends AuthorizingRealm { public class OAuth2Realm extends AuthorizingRealm {
@Autowired @Autowired
private ShiroService shiroService; private ShiroService shiroService;
@Autowired
private MemberDao memberDao;
@Override @Override
public boolean supports(AuthenticationToken token) { public boolean supports(AuthenticationToken token) {
return token instanceof OAuth2Token; return token instanceof OAuth2Token;
...@@ -67,19 +70,22 @@ public class OAuth2Realm extends AuthorizingRealm { ...@@ -67,19 +70,22 @@ public class OAuth2Realm extends AuthorizingRealm {
} }
//查询用户信息 //查询用户信息
SysUserEntity user = null; SysUserEntity user = null;
SimpleAuthenticationInfo info=null;
if(accessToken.startsWith("qianduan_")) { if(accessToken.startsWith("qianduan_")) {
//todo //todo
MemberEntity memberEntity = memberDao.selectById(tokenEntity.getUserId());
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());
} }
SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, accessToken, getName()); // SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, accessToken, getName());
return info; return info;
} }
} }
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