mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-03 11:05:58 +00:00
update 优化登出方法
This commit is contained in:
@@ -82,12 +82,7 @@ public class TokenController {
|
||||
@ApiOperation("登出方法")
|
||||
@DeleteMapping("logout")
|
||||
public R<Void> logout() {
|
||||
try {
|
||||
String username = LoginHelper.getUsername();
|
||||
StpUtil.logout();
|
||||
sysLoginService.logout(username);
|
||||
} catch (NotLoginException e) {
|
||||
}
|
||||
sysLoginService.logout();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.auth.service;
|
||||
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@@ -79,8 +80,16 @@ public class SysLoginService {
|
||||
return StpUtil.getTokenValue();
|
||||
}
|
||||
|
||||
public void logout(String loginName) {
|
||||
recordLogininfor(loginName, Constants.LOGOUT, MessageUtils.message("user.logout.success"));
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
public void logout() {
|
||||
try {
|
||||
String username = LoginHelper.getUsername();
|
||||
StpUtil.logout();
|
||||
recordLogininfor(username, Constants.LOGOUT, MessageUtils.message("user.logout.success"));
|
||||
} catch (NotLoginException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user