refactor: centralize validation, error handling, and formatting logic
Extract shared auth logic and validation rules to shared/auth.ts Introduce utility functions for HTTP errors and user input parsing Standardize error messages and date formatting across the app
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { AuthUser } from '~~/shared/auth'
|
||||
import { needsUserOnboarding, type AuthUser } from '~~/shared/auth'
|
||||
|
||||
export function useAuth() {
|
||||
const user = useState<AuthUser | null>('auth:user', () => null)
|
||||
@@ -8,9 +8,7 @@ export function useAuth() {
|
||||
|
||||
const isAuthenticated = computed(() => Boolean(user.value))
|
||||
const isSuperAdmin = computed(() => user.value?.role === 'super_admin')
|
||||
const needsOnboarding = computed(() => {
|
||||
return Boolean(user.value && (user.value.mustChangePassword || user.value.needsPasskeySetup))
|
||||
})
|
||||
const needsOnboarding = computed(() => needsUserOnboarding(user.value))
|
||||
|
||||
async function fetchSession(force = false) {
|
||||
if (loaded.value && !force) {
|
||||
|
||||
Reference in New Issue
Block a user