feat(auth): 实现用户菜单及登出功能
- 在Header组件添加用户下拉菜单,支持显示用户名和操作选项 - 新增点击文档隐藏菜单的事件监听与清理 - 实现登出功能,调用后端登出接口,清理登录状态并跳转主页 - 路由新增管理员页面/admid及其组件admid.vue - 删除unused的首页index.vue页面文件 - 后端新增登出接口/logout,支持用户会话注销 - 修正登录服务实现,修复密码匹配逻辑错误 - 客户端api新增logout接口调用后端登出功能
This commit is contained in:
@@ -33,6 +33,18 @@ public class LoginController {
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("logout")
|
||||
@ApiOperationLog(description = "登出")
|
||||
public Response<Void> logout() {
|
||||
try {
|
||||
StpUtil.logout();
|
||||
return Response.success();
|
||||
} catch (Exception e) {
|
||||
log.error("登出失败 {}", e.getMessage());
|
||||
return Response.fail("登出失败 " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("sendVerificationCode")
|
||||
@ApiOperationLog(description = "发送验证码")
|
||||
public Response<Void> sendVerificationCode(@RequestBody VerificationCodeReqVO verificationCodeReqVO) {
|
||||
|
||||
@@ -59,8 +59,7 @@ public class LoginServiceImpl implements LoginService {
|
||||
|
||||
if (reqPassword != null && passwordEncoder.matches(reqPassword, userDO.getPassword())) {
|
||||
StpUtil.login(userDO.getId());
|
||||
throw new RuntimeException("密码错误");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new RuntimeException("登录错误");
|
||||
|
||||
Reference in New Issue
Block a user