Some checks are pending
E2E / Playwright e2e (push) Waiting to run
- Added SessionGuard component to manage session expiration and online status. - Updated AuthProvider to streamline session fetching and handling. - Introduced IdentityProvidersSection for managing OAuth, SAML, and LDAP identity providers. - Implemented identity provider guides for easier configuration. - Enhanced mail settings with infinite scroll option for improved user experience. - Updated global styles and layout components for better consistency across the application.
30 lines
690 B
TypeScript
30 lines
690 B
TypeScript
"use client"
|
|
|
|
import { create } from "zustand"
|
|
|
|
export type SessionGuardStatus = "idle" | "offline" | "expired"
|
|
|
|
interface SessionGuardState {
|
|
status: SessionGuardStatus
|
|
setOffline: () => void
|
|
setExpired: () => void
|
|
clear: () => void
|
|
}
|
|
|
|
export const useSessionGuardStore = create<SessionGuardState>((set, get) => ({
|
|
status: "idle",
|
|
setOffline: () => {
|
|
if (get().status === "expired") return
|
|
set({ status: "offline" })
|
|
},
|
|
setExpired: () => {
|
|
if (get().status === "expired") return
|
|
set({ status: "expired" })
|
|
},
|
|
clear: () => set({ status: "idle" }),
|
|
}))
|
|
|
|
export function isSessionExpired() {
|
|
return useSessionGuardStore.getState().status === "expired"
|
|
}
|