Init
This commit is contained in:
23
resources/js/composables/useAuth.ts
Normal file
23
resources/js/composables/useAuth.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { AuthConfig, Flash, User } from '@/types'
|
||||
import { usePage } from '@inertiajs/vue3'
|
||||
import { computed } from 'vue'
|
||||
|
||||
export function useAuth() {
|
||||
const page = usePage<{
|
||||
auth: { user: User | null }
|
||||
flash: Flash
|
||||
authConfig: AuthConfig
|
||||
}>()
|
||||
|
||||
const user = computed(() => page.props.auth.user)
|
||||
const isAuthenticated = computed(() => !!page.props.auth.user)
|
||||
const flash = computed(() => page.props.flash)
|
||||
const config = computed(() => page.props.authConfig)
|
||||
|
||||
return {
|
||||
user,
|
||||
isAuthenticated,
|
||||
flash,
|
||||
config,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user