From e190d3f74422bc8af3fc321edf321ab794c76980 Mon Sep 17 00:00:00 2001
From: parsa aghaei
Date: Sat, 8 Aug 2026 18:57:43 +0330
Subject: [PATCH] fix(admin-auth & contact): persist admin token in
localStorage and allow ADMIN role on contact submission endpoints
---
backend/src/contact/contact.controller.ts | 6 +--
.../admin-panel/src/store/adminAuthStore.ts | 38 +++++++++++--------
2 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/backend/src/contact/contact.controller.ts b/backend/src/contact/contact.controller.ts
index b46f90e8..7da01575 100644
--- a/backend/src/contact/contact.controller.ts
+++ b/backend/src/contact/contact.controller.ts
@@ -37,7 +37,7 @@ export class ContactController {
}
@UseGuards(JwtAuthGuard, RolesGuard)
- @Roles('Admin', 'SuperAdmin')
+ @Roles('ADMIN', 'Admin', 'SUPERADMIN', 'SuperAdmin', 'ADMIN_EXPERT')
@Get('submissions')
async getAllSubmissions(
@Query('page') page?: string,
@@ -52,7 +52,7 @@ export class ContactController {
}
@UseGuards(JwtAuthGuard, RolesGuard)
- @Roles('Admin', 'SuperAdmin')
+ @Roles('ADMIN', 'Admin', 'SUPERADMIN', 'SuperAdmin', 'ADMIN_EXPERT')
@Put('submissions/:id')
async updateSubmissionStatus(
@Param('id') id: string,
@@ -66,7 +66,7 @@ export class ContactController {
}
@UseGuards(JwtAuthGuard, RolesGuard)
- @Roles('Admin', 'SuperAdmin')
+ @Roles('ADMIN', 'Admin', 'SUPERADMIN', 'SuperAdmin', 'ADMIN_EXPERT')
@Put('info')
async updateContactInfo(
@Body()
diff --git a/frontend/admin-panel/src/store/adminAuthStore.ts b/frontend/admin-panel/src/store/adminAuthStore.ts
index 99d654e8..9fc97e9d 100644
--- a/frontend/admin-panel/src/store/adminAuthStore.ts
+++ b/frontend/admin-panel/src/store/adminAuthStore.ts
@@ -1,22 +1,30 @@
import { create } from 'zustand';
+import { persist } from 'zustand/middleware';
import type { AuthState, AdminUser } from '../types/admin';
-export const useAdminAuthStore = create((set) => ({
- accessToken: null,
- adminUser: null,
- isAuthenticated: false,
-
- setAuth: (accessToken: string, adminUser: AdminUser) =>
- set({
- accessToken,
- adminUser,
- isAuthenticated: true,
- }),
-
- clearAuth: () =>
- set({
+export const useAdminAuthStore = create()(
+ 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',
+ }
+ )
+);