bug 修改
This commit is contained in:
parent
d991c59ba7
commit
ff8fd57c16
|
|
@ -3,6 +3,7 @@ package com.bonus.auth.controller;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.system.api.domain.SysUser;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
|
@ -33,6 +34,18 @@ public class TokenController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysLoginService sysLoginService;
|
private SysLoginService sysLoginService;
|
||||||
|
|
||||||
|
@PostMapping("isLogin")
|
||||||
|
public R<?> isLogin(@RequestBody LoginBody form) {
|
||||||
|
LoginUser userInfo;
|
||||||
|
if ("mobile".equals(form.getLoginType())) {
|
||||||
|
userInfo = sysLoginService.login(form.getMobile(), form.getPassword(), form.getLoginType());
|
||||||
|
} else {
|
||||||
|
userInfo = sysLoginService.login(form.getUsername(), form.getPassword(), form.getLoginType());
|
||||||
|
}
|
||||||
|
SysUser sysUser = userInfo.getSysUser();
|
||||||
|
return R.ok(tokenService.isLogin(String.valueOf(sysUser.getUserId())));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户登录
|
* 用户登录
|
||||||
*
|
*
|
||||||
|
|
@ -72,10 +85,15 @@ public class TokenController {
|
||||||
try {
|
try {
|
||||||
String token = SecurityUtils.getToken(request);
|
String token = SecurityUtils.getToken(request);
|
||||||
if (StringUtils.isNotEmpty(token)) {
|
if (StringUtils.isNotEmpty(token)) {
|
||||||
String username = JwtUtils.getUserName(token);
|
String key = JwtUtils.getUserKey(token);
|
||||||
String userId = JwtUtils.getUserId(token);
|
boolean key1 = tokenService.isKey(key);
|
||||||
AuthUtil.logoutByToken(token);
|
if (key1) {
|
||||||
sysLoginService.logout(username, userId);
|
String username = JwtUtils.getUserName(token);
|
||||||
|
String userId = JwtUtils.getUserId(token);
|
||||||
|
AuthUtil.logoutByToken(token);
|
||||||
|
tokenService.delExistingToken(Long.valueOf(userId));
|
||||||
|
sysLoginService.logout(username, userId);
|
||||||
|
}
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue