feat: refactor admin authentication to staff authentication with updated cookie handling
This commit is contained in:
@@ -9,18 +9,18 @@ import { handleCookie } from '~/libs/cookies'
|
||||
import type { Route } from './+types/_admin.lg-admin'
|
||||
|
||||
export const loader = async ({ request }: Route.LoaderArgs) => {
|
||||
const { adminToken } = await handleCookie(request)
|
||||
const { staffToken } = await handleCookie(request)
|
||||
const { pathname } = new URL(request.url)
|
||||
const isAuthPage = AUTH_PAGES.includes(pathname)
|
||||
let adminData
|
||||
|
||||
if (!isAuthPage && !adminToken) {
|
||||
if (!isAuthPage && !staffToken) {
|
||||
throw redirect('/lg-admin/login')
|
||||
}
|
||||
|
||||
if (adminToken) {
|
||||
if (staffToken) {
|
||||
const { data } = await getStaff({
|
||||
accessToken: adminToken,
|
||||
accessToken: staffToken,
|
||||
})
|
||||
adminData = data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user