mirror of
https://github.com/BgaSol/sol-cloud
synced 2026-05-22 16:48:22 +00:00
refactor(user): update user-related code
- Remove permission check for logout endpoint - Optimize login logic
This commit is contained in:
parent
2b9b0423ed
commit
628a56cdfa
2 changed files with 17 additions and 4 deletions
|
|
@ -51,7 +51,7 @@ public class UserController extends BaseController<
|
|||
|
||||
@PostMapping("/logout")
|
||||
@Operation(summary = "用户登出", operationId = "logout")
|
||||
@SaCheckPermission({"user:logout"})
|
||||
// @SaCheckPermission({"user:logout"})
|
||||
public BaseVo<?> logout() {
|
||||
this.loginService.logout();
|
||||
return BaseVo.success("登出成功");
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import com.bgasol.web.system.user.mapper.UserMapper;
|
|||
import com.pig4cloud.captcha.ArithmeticCaptcha;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -21,6 +22,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.bgasol.common.constant.value.SystemConfigValues.ADMIN_USER_ID;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Transactional
|
||||
|
|
@ -81,9 +84,19 @@ public class LoginService {
|
|||
log.error("密码错误");
|
||||
throw new BaseException("用户名或密码错误");
|
||||
}
|
||||
if (userEntity.getLocked()) {
|
||||
log.error("用户已锁定");
|
||||
throw new BaseException("用户已锁定");
|
||||
|
||||
if (!ADMIN_USER_ID.equals(userEntity.getId())) {
|
||||
userEntity = this.userService.findById(userEntity.getId());
|
||||
if (userEntity.getLocked()) {
|
||||
log.error("用户已锁定");
|
||||
throw new BaseException("用户已锁定");
|
||||
}
|
||||
if (ObjectUtils.isEmpty(userEntity.getRoles())) {
|
||||
throw new BaseException("用户未绑定角色,无法登录");
|
||||
}
|
||||
if (ObjectUtils.isEmpty(userEntity.getDepartment())) {
|
||||
throw new BaseException("用户未绑定部门,无法登录");
|
||||
}
|
||||
}
|
||||
StpUtil.login(userEntity.getId());
|
||||
return StpUtil.getTokenInfo();
|
||||
|
|
|
|||
Loading…
Reference in a new issue