feat: refactor admin authentication to staff authentication with updated cookie handling

This commit is contained in:
Ardeman
2025-03-03 16:47:59 +08:00
parent 4f4e94389e
commit 459e25c010
11 changed files with 120 additions and 90 deletions
+4 -4
View File
@@ -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
}