mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	@@ -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) {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user