|
@@ -7,8 +7,11 @@
|
|
|
|
|
|
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.model.Result;
|
|
|
import cn.com.qmth.examcloud.app.model.UserInfo;
|
|
|
+import cn.com.qmth.examcloud.app.model.UserToken;
|
|
|
+import cn.com.qmth.examcloud.app.service.RedisService;
|
|
|
import cn.com.qmth.examcloud.app.service.UserAuthService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -17,9 +20,8 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-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;
|
|
|
|
|
|
/**
|
|
|
* 认证中心相关接口
|
|
@@ -33,11 +35,13 @@ public class UserAuthRestController {
|
|
|
private final static Logger log = LoggerFactory.getLogger(UserAuthRestController.class);
|
|
|
@Autowired
|
|
|
private UserAuthService userAuthService;
|
|
|
+ @Autowired
|
|
|
+ private RedisService redisService;
|
|
|
|
|
|
@ApiOperation(value = "登录接口")
|
|
|
@RequestMapping(value = "/user/login", method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
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, HttpServletRequest request) throws Exception {
|
|
|
+ @RequestParam(required = false) Long rootOrgId, @RequestParam(required = false) String domain) throws Exception {
|
|
|
if (accountType == null) {
|
|
|
accountType = COMMON_ACCOUNT_TYPE;
|
|
|
}
|
|
@@ -46,15 +50,10 @@ public class UserAuthRestController {
|
|
|
//获取当前登录用户信息
|
|
|
UserInfo userInfo = result.getData();
|
|
|
UserToken userToken = new UserToken(account, password, accountType, rootOrgId, domain, userInfo.getKey(), userInfo.getToken());
|
|
|
-
|
|
|
- //存放登录信息到Session中
|
|
|
+ //将登录信息存放到Redis中
|
|
|
String sessionKey = StrUtils.uuid();
|
|
|
- HttpSession session = request.getSession();
|
|
|
- //session.setMaxInactiveInterval(EXPIRE_TIME);
|
|
|
- session.setMaxInactiveInterval(60);
|
|
|
- session.setAttribute(sessionKey, userToken);
|
|
|
- log.debug("token:" + userToken.getToken() + " sessionId:" + sessionKey);
|
|
|
-
|
|
|
+ redisService.cacheUserToken(sessionKey, userToken, REDIS_EXPIRE_TIME);
|
|
|
+ log.debug("token:" + userToken.getToken() + " sessionKey:" + sessionKey);
|
|
|
//替换Token为本地SessionKey
|
|
|
userInfo.setToken(sessionKey);
|
|
|
}*/
|