BOC v1.0: RS256 auth, Ledger integration, Prometheus metrics, CI/CD, backup
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { useEffect } from 'react'
|
||||
import { useAuthStore } from '@/stores/authStore'
|
||||
import { authApi } from '@/lib/api'
|
||||
|
||||
export function useAuth() {
|
||||
const { token, user, isAuthenticated, login, logout, setUser } = useAuthStore()
|
||||
|
||||
useEffect(() => {
|
||||
if (token && !user) {
|
||||
authApi.me()
|
||||
.then((data) => setUser(data.user as unknown as Parameters<typeof setUser>[0]))
|
||||
.catch(() => logout())
|
||||
}
|
||||
}, [token, user, setUser, logout])
|
||||
|
||||
return { token, user, isAuthenticated, login, logout }
|
||||
}
|
||||
Reference in New Issue
Block a user