fix(admin-auth & contact): persist admin token in localStorage and allow ADMIN role on contact submission endpoints
Deploy Canina / deploy (push) Failing after 28s

This commit is contained in:
parsa aghaei committed 2026-08-08 18:57:43 +03:30
1 parent e3ff345608
commit e190d3f744
2 files changed
+26 -18

No files matched your search

@@ -1,22 +1,30 @@
import { create } from 'zustand';
import { persist } from 'zustand/middleware';
import type { AuthState, AdminUser } from '../types/admin';
export const useAdminAuthStore = create<AuthState>((set) => ({
accessToken: null,
adminUser: null,
isAuthenticated: false,
setAuth: (accessToken: string, adminUser: AdminUser) =>
set({
accessToken,
adminUser,
isAuthenticated: true,
}),
clearAuth: () =>
set({
export const useAdminAuthStore = create<AuthState>()(
persist(
(set) => ({
accessToken: null,
adminUser: null,
isAuthenticated: false,
setAuth: (accessToken: string, adminUser: AdminUser) =>
set({
accessToken,
adminUser,
isAuthenticated: true,
}),
clearAuth: () =>
set({
accessToken: null,
adminUser: null,
isAuthenticated: false,
}),
}),
}));
{
name: 'canina_admin_auth',
}
)
);