fix(admin-auth & contact): persist admin token in localStorage and allow ADMIN role on contact submission endpoints
Deploy Canina / deploy (push) Failing after 28s
Deploy Canina / deploy (push) Failing after 28s
This commit is contained in:
1 parent
e3ff345608
commit
e190d3f744
2 files changed
+26
-18
No files matched your search
@@ -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()
|
||||
|
||||
@@ -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',
|
||||
}
|
||||
)
|
||||
);
|
||||
Reference in new issue
Block a user