|
@@ -11,6 +11,8 @@ import com.ozs.common.utils.StringUtils;
|
|
|
import com.ozs.framework.web.service.TokenService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import com.ozs.common.constant.Constants;
|
|
|
import com.ozs.common.core.domain.AjaxResult;
|
|
@@ -22,6 +24,8 @@ import com.ozs.framework.web.service.SysLoginService;
|
|
|
import com.ozs.framework.web.service.SysPermissionService;
|
|
|
import com.ozs.system.service.ISysMenuService;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
/**
|
|
|
* 登录验证
|
|
|
*
|
|
@@ -46,6 +50,9 @@ public class SysLoginController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
+ // 令牌自定义标识
|
|
|
+ @Value("${token.header}")
|
|
|
+ private String header;
|
|
|
|
|
|
/**
|
|
|
* 登录方法
|
|
@@ -54,13 +61,10 @@ public class SysLoginController extends BaseController {
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@PostMapping("/login")
|
|
|
- public AjaxResult login(@RequestBody LoginBody loginBody) {
|
|
|
- // 判断账号是否在其他电脑登陆
|
|
|
- String userId = loginService.getUserIdByUserName(loginBody.getUsername());
|
|
|
- log.info("111111111-----" + userId);
|
|
|
- if (!StringUtils.isEmpty(userId)) {
|
|
|
- log.info("22222222-----" + userId);
|
|
|
- redisCache.deleteObject(userId);
|
|
|
+ public AjaxResult login(@RequestBody LoginBody loginBody, HttpServletRequest request) {
|
|
|
+ // 判断账号是否在其他电脑登陆/**/
|
|
|
+ if (!ObjectUtils.isEmpty(request.getHeader(this.header))) {
|
|
|
+ request.removeAttribute(header);
|
|
|
}
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
// 生成令牌
|