🎉 initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { createServerFn } from '@tanstack/react-start'
|
||||
import { getRequest } from '@tanstack/react-start/server'
|
||||
|
||||
export async function getStaffSession() {
|
||||
const { getAuth } = await import('#/lib/auth-instance')
|
||||
return getAuth().api.getSession({ headers: getRequest().headers })
|
||||
}
|
||||
|
||||
export async function requireStaffSession() {
|
||||
const session = await getStaffSession()
|
||||
|
||||
if (!session) {
|
||||
throw new Error('Not signed in')
|
||||
}
|
||||
|
||||
return session
|
||||
}
|
||||
|
||||
export const getCurrentStaffUser = createServerFn({ method: 'GET' }).handler(async () => {
|
||||
const session = await getStaffSession()
|
||||
return session?.user ?? null
|
||||
})
|
||||
Reference in New Issue
Block a user