修复用户登陆时的用户禁用状态判断
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.yupi.springbootinit.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.yupi.springbootinit.common.BaseResponse;
|
||||
@@ -30,7 +31,7 @@ public class UserController {
|
||||
@Resource
|
||||
private SystemUsersService usersService;
|
||||
|
||||
// 测试登录,浏览器访问: http://localhost:8081/user/doLogin?username=zhang&password=123456
|
||||
// 用户登陆接口
|
||||
@PostMapping("doLogin")
|
||||
public BaseResponse<SystemUsersVO> doLogin(@RequestBody SystemUsersDTO usersDTO) {
|
||||
SystemUsers user = usersService.getUserByUserName(usersDTO.getUsername());
|
||||
@@ -42,18 +43,15 @@ public class UserController {
|
||||
throw new BusinessException(ErrorCode.USERNAME_OR_PASSWORD_ERROR);
|
||||
}
|
||||
|
||||
if (CommonStatusEnum.isDisable(user.getStatus())) {
|
||||
if (CommonStatusEnum.isDisable(Integer.valueOf(user.getStatus()))) {
|
||||
throw new BusinessException(ErrorCode.USER_DISABLE);
|
||||
}
|
||||
SystemUsersVO systemUsersVO = new SystemUsersVO();
|
||||
BeanUtil.copyProperties(user, systemUsersVO);
|
||||
StpUtil.login(user.getId());
|
||||
systemUsersVO.setTokenName(StpUtil.getTokenName());
|
||||
systemUsersVO.setTokenValue(StpUtil.getTokenValue());
|
||||
return ResultUtils.success(systemUsersVO);
|
||||
}
|
||||
|
||||
// // 查询登录状态,浏览器访问: http://localhost:8081/user/isLogin
|
||||
// @RequestMapping("isLogin")
|
||||
// public String isLogin() {
|
||||
// return "当前会话是否登录:" + StpUtil.isLogin();
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user