!192 优化登出方法

Merge pull request !192 from zendwang/dev
feature/model
疯狂的狮子Li 2 years ago committed by Gitee
commit b9931cda30
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -1,7 +1,5 @@
package com.ruoyi.web.controller.system;
import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.stp.StpUtil;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.R;
@ -102,12 +100,7 @@ public class SysLoginController {
@ApiOperation("登出方法")
@PostMapping("/logout")
public R<Void> logout() {
try {
String username = LoginHelper.getUsername();
StpUtil.logout();
loginService.logout(username);
} catch (NotLoginException e) {
}
loginService.logout();
return R.ok("退出成功");
}

@ -1,5 +1,6 @@
package com.ruoyi.system.service;
import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.secure.BCrypt;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
@ -113,9 +114,16 @@ public class SysLoginService {
return StpUtil.getTokenValue();
}
public void logout(String loginName) {
asyncService.recordLogininfor(loginName, Constants.LOGOUT, MessageUtils.message("user.logout.success"), ServletUtils.getRequest());
/**
* 退
*/
public void logout() {
try {
String username = LoginHelper.getUsername();
StpUtil.logout();
asyncService.recordLogininfor(username, Constants.LOGOUT, MessageUtils.message("user.logout.success"), ServletUtils.getRequest());
} catch (NotLoginException e) {
}
}
/**

Loading…
Cancel
Save