mirror of
https://github.com/GlueOps/autoglue.git
synced 2026-02-13 12:50:05 +01:00
feat: adding background jobs ui page and apis - requires user is_admin to be set to true
This commit is contained in:
10
ui/src/hooks/use-auth-actions.ts
Normal file
10
ui/src/hooks/use-auth-actions.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useCallback } from "react"
|
||||
import { logoutEverywhere } from "@/auth/logout.ts"
|
||||
|
||||
export function useAuthActions() {
|
||||
const logout = useCallback(() => {
|
||||
return logoutEverywhere()
|
||||
}, [])
|
||||
|
||||
return { logout }
|
||||
}
|
||||
17
ui/src/hooks/use-auth.ts
Normal file
17
ui/src/hooks/use-auth.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useSyncExternalStore } from "react"
|
||||
import { authStore, type TokenPair } from "@/auth/store.ts"
|
||||
|
||||
export const useAuth = () => {
|
||||
const tokens = useSyncExternalStore<TokenPair | null>(
|
||||
(cb) => authStore.subscribe(cb),
|
||||
() => authStore.get(),
|
||||
() => authStore.get() // server snapshot (SSR)
|
||||
)
|
||||
|
||||
return {
|
||||
tokens,
|
||||
authed: !!tokens?.access_token,
|
||||
isExpired: authStore.isExpired(),
|
||||
willExpireSoon: authStore.willExpireSoon(),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user