feat: 登录改为 Casdoor 统一身份认证(SSO),重建用户体系
- 移除内置密码注册/登录/改密/删号/头像,统一走 Casdoor OIDC 授权码 - 服务端 casdoor-nodejs-sdk:code 换 token + 证书公钥验签 + get-account 补齐资料 - 用户表重建为 provider+provider_id(Casdoor sub 为准),邮箱不再唯一 - 管理员由 Casdoor token 的 isAdmin/IsAdmin 字段或 admin 角色判定,删除角色切换接口 - 前端登录弹窗改为申统认证跳转,注册去 Casdoor;后台用户列表只读角色 - 会话沿用 an_session httpOnly Cookie,requireUser/requireAdmin 守卫保留 - 配置注入 deploy.sh/.env.example;新增 casdoor 单测,删除 password 单测
This commit is contained in:
+8
-30
@@ -2,55 +2,33 @@ import { defineStore } from 'pinia'
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
/**
|
||||
* 登录/注册弹窗全局状态。
|
||||
* Header、个人中心、收藏/评论组件等都可直接 openLogin() 唤起登录弹窗,
|
||||
* 避免层层 prop/事件传递。
|
||||
* 登录弹窗全局状态(统一认证跳转由 LoginModal 触发)。
|
||||
* Header、个人中心、收藏/评论组件等都可直接 openLogin() 唤起,
|
||||
* 避免层层 prop/事件传递。注册账号统一跳转 Casdoor 完成,此处不再提供注册弹窗。
|
||||
*/
|
||||
export const useAuthModalStore = defineStore('authModal', () => {
|
||||
const isLoginOpen = ref(false)
|
||||
const isRegisterOpen = ref(false)
|
||||
|
||||
// 任一弹窗打开时锁定背景滚动
|
||||
// 弹窗打开时锁定背景滚动
|
||||
watch(
|
||||
() => [isLoginOpen.value, isRegisterOpen.value],
|
||||
([login, register]) => {
|
||||
() => isLoginOpen.value,
|
||||
(open) => {
|
||||
if (typeof document === 'undefined') return
|
||||
document.body.style.overflow = login || register ? 'hidden' : ''
|
||||
document.body.style.overflow = open ? 'hidden' : ''
|
||||
},
|
||||
)
|
||||
|
||||
const openLogin = () => {
|
||||
isRegisterOpen.value = false
|
||||
isLoginOpen.value = true
|
||||
}
|
||||
|
||||
const openRegister = () => {
|
||||
isLoginOpen.value = false
|
||||
isRegisterOpen.value = true
|
||||
}
|
||||
|
||||
const closeAll = () => {
|
||||
isLoginOpen.value = false
|
||||
isRegisterOpen.value = false
|
||||
}
|
||||
|
||||
const switchToRegister = () => {
|
||||
isLoginOpen.value = false
|
||||
isRegisterOpen.value = true
|
||||
}
|
||||
|
||||
const switchToLogin = () => {
|
||||
isRegisterOpen.value = false
|
||||
isLoginOpen.value = true
|
||||
}
|
||||
|
||||
return {
|
||||
isLoginOpen,
|
||||
isRegisterOpen,
|
||||
openLogin,
|
||||
openRegister,
|
||||
closeAll,
|
||||
switchToRegister,
|
||||
switchToLogin,
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user