|
@@ -8,6 +8,7 @@
|
|
package cn.com.qmth.examcloud.app.controller.version_1_0;
|
|
package cn.com.qmth.examcloud.app.controller.version_1_0;
|
|
|
|
|
|
import cn.com.qmth.examcloud.app.core.utils.StrUtils;
|
|
import cn.com.qmth.examcloud.app.core.utils.StrUtils;
|
|
|
|
+import cn.com.qmth.examcloud.app.model.LoginType;
|
|
import cn.com.qmth.examcloud.app.model.Result;
|
|
import cn.com.qmth.examcloud.app.model.Result;
|
|
import cn.com.qmth.examcloud.app.model.UserInfo;
|
|
import cn.com.qmth.examcloud.app.model.UserInfo;
|
|
import cn.com.qmth.examcloud.app.model.UserToken;
|
|
import cn.com.qmth.examcloud.app.model.UserToken;
|
|
@@ -22,8 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
-import static cn.com.qmth.examcloud.app.model.Constants.COMMON_ACCOUNT_TYPE;
|
|
|
|
-import static cn.com.qmth.examcloud.app.model.Constants.REDIS_EXPIRE_TIME;
|
|
|
|
|
|
+import static cn.com.qmth.examcloud.app.model.Constants.APP_SESSION_EXPIRE_TIME;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 认证中心相关接口
|
|
* 认证中心相关接口
|
|
@@ -47,17 +47,17 @@ public class UserAuthRestController {
|
|
public Result<UserInfo> login(@RequestParam String account, @RequestParam String password, @RequestParam(required = false) String accountType,
|
|
public Result<UserInfo> login(@RequestParam String account, @RequestParam String password, @RequestParam(required = false) String accountType,
|
|
@RequestParam(required = false) Long rootOrgId, @RequestParam(required = false) String domain) throws Exception {
|
|
@RequestParam(required = false) Long rootOrgId, @RequestParam(required = false) String domain) throws Exception {
|
|
if (accountType == null) {
|
|
if (accountType == null) {
|
|
- accountType = COMMON_ACCOUNT_TYPE;
|
|
|
|
|
|
+ accountType = LoginType.COMMON_LOGIN_NAME.name();
|
|
}
|
|
}
|
|
Result<UserInfo> result = userAuthService.login(account, password, accountType, rootOrgId, domain);
|
|
Result<UserInfo> result = userAuthService.login(account, password, accountType, rootOrgId, domain);
|
|
- /*if (result.isSuccess()) {
|
|
|
|
|
|
+ /*if (result.isSuccess()) {
|
|
//获取当前登录用户信息
|
|
//获取当前登录用户信息
|
|
UserInfo userInfo = result.getData();
|
|
UserInfo userInfo = result.getData();
|
|
//封装原始登录信息
|
|
//封装原始登录信息
|
|
UserToken userToken = new UserToken(account, password, accountType, rootOrgId, domain, userInfo.getKey(), userInfo.getToken());
|
|
UserToken userToken = new UserToken(account, password, accountType, rootOrgId, domain, userInfo.getKey(), userInfo.getToken());
|
|
//将原始登录信息存放到Redis中
|
|
//将原始登录信息存放到Redis中
|
|
String redisKey = StrUtils.md5Key(userInfo.getKey());
|
|
String redisKey = StrUtils.md5Key(userInfo.getKey());
|
|
- redisService.cacheUserToken(redisKey, userToken, REDIS_EXPIRE_TIME);
|
|
|
|
|
|
+ redisService.cacheUserToken(redisKey, userToken, APP_SESSION_EXPIRE_TIME);
|
|
log.debug("redisKey:" + redisKey + " loginToken:" + userToken.getToken());
|
|
log.debug("redisKey:" + redisKey + " loginToken:" + userToken.getToken());
|
|
//替换login token为缓存的redisKey,并作为接口的结果返回
|
|
//替换login token为缓存的redisKey,并作为接口的结果返回
|
|
userInfo.setToken(redisKey);
|
|
userInfo.setToken(redisKey);
|