refactor(frontend): merge authserver web login
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { authApi } from '@/api/auth'
|
||||
import { redirectToSSO } from '@/utils/sso'
|
||||
|
||||
export function useAuth() {
|
||||
const router = useRouter()
|
||||
const authStore = useAuthStore()
|
||||
|
||||
const login = async (username: string, password: string) => {
|
||||
@@ -16,12 +15,12 @@ export function useAuth() {
|
||||
const logout = async () => {
|
||||
await authApi.logout()
|
||||
authStore.clearAuth()
|
||||
router.push('/login')
|
||||
redirectToSSO()
|
||||
}
|
||||
|
||||
const checkAuth = () => {
|
||||
if (!authStore.isLoggedIn()) {
|
||||
router.push('/login')
|
||||
redirectToSSO()
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user