Update role references from Role to UserRole for consistency
This commit is contained in:
parent
7a72e56dbd
commit
fec108d802
@ -31,7 +31,6 @@ export const validateParticipantDeletionRequest = (req: Request, res: Response,
|
||||
}
|
||||
|
||||
req.query = data!;
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
|
||||
@ -39,12 +39,11 @@ export const BulkDeleteRecordingsSchema = z.object({
|
||||
|
||||
return arg;
|
||||
},
|
||||
z.array(nonEmptySanitizedString('recordingId'))
|
||||
.default([])
|
||||
z.array(nonEmptySanitizedString('recordingId')).default([])
|
||||
)
|
||||
});
|
||||
|
||||
const GetRecordingsFiltersSchema: z.ZodType<MeetRecordingFilters> = z.object({
|
||||
const GetRecordingsFiltersSchema: z.ZodType<MeetRecordingFilters> = z.object({
|
||||
maxItems: z.coerce
|
||||
.number()
|
||||
.int()
|
||||
@ -64,7 +63,6 @@ export const withValidStartRecordingRequest = (req: Request, res: Response, next
|
||||
}
|
||||
|
||||
req.body = data;
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
@ -76,7 +74,6 @@ export const withValidRecordingId = (req: Request, res: Response, next: NextFunc
|
||||
}
|
||||
|
||||
req.params.recordingId = data.recordingId;
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
@ -102,7 +99,6 @@ export const withValidRecordingBulkDeleteRequest = (req: Request, res: Response,
|
||||
}
|
||||
|
||||
req.query.recordingIds = data.recordingIds.join(',');
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import {
|
||||
updateAppearancePreferences
|
||||
} from '../controllers/global-preferences/appearance-preferences.controller.js';
|
||||
import { withAuth, tokenAndRoleValidator, apiKeyValidator } from '../middlewares/auth.middleware.js';
|
||||
import { Role } from '@typings-ce';
|
||||
import { UserRole } from '@typings-ce';
|
||||
|
||||
export const preferencesRouter = Router();
|
||||
|
||||
@ -14,11 +14,11 @@ preferencesRouter.use(bodyParser.json());
|
||||
|
||||
preferencesRouter.put(
|
||||
'/appearance',
|
||||
withAuth(apiKeyValidator, tokenAndRoleValidator(Role.ADMIN)),
|
||||
withAuth(apiKeyValidator, tokenAndRoleValidator(UserRole.ADMIN)),
|
||||
updateAppearancePreferences
|
||||
);
|
||||
preferencesRouter.get(
|
||||
'/appearance',
|
||||
withAuth(apiKeyValidator, tokenAndRoleValidator(Role.ADMIN)),
|
||||
withAuth(apiKeyValidator, tokenAndRoleValidator(UserRole.ADMIN)),
|
||||
getAppearancePreferences
|
||||
);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, CanActivateFn, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { AuthService } from '../services';
|
||||
import { Role } from '@lib/typings/ce';
|
||||
import { UserRole } from '@lib/typings/ce';
|
||||
|
||||
export const checkUserAuthenticatedGuard: CanActivateFn = async (
|
||||
route: ActivatedRouteSnapshot,
|
||||
@ -21,7 +21,7 @@ export const checkUserAuthenticatedGuard: CanActivateFn = async (
|
||||
|
||||
// Check if the user has the expected roles
|
||||
const { expectedRoles } = route.data;
|
||||
const userRole = authService.isAdmin() ? Role.ADMIN : Role.USER;
|
||||
const userRole = authService.isAdmin() ? UserRole.ADMIN : UserRole.USER;
|
||||
|
||||
if (!expectedRoles.includes(userRole)) {
|
||||
// Redirect to the page specified in the route data when user has an invalid role
|
||||
@ -1,4 +1,4 @@
|
||||
export * from './admin-auth.guard';
|
||||
export * from './auth.guard';
|
||||
export * from './extract-query-params.guard';
|
||||
export * from './validate-room-access.guard';
|
||||
export * from './application-mode.guard';
|
||||
|
||||
@ -27,7 +27,7 @@ import {
|
||||
RoomFormComponent
|
||||
} from '../pages';
|
||||
import { LoginComponent } from '@lib/pages/login/login.component';
|
||||
import { Role } from '@lib/typings/ce';
|
||||
import { UserRole } from '@lib/typings/ce';
|
||||
|
||||
export const baseRoutes: Routes = [
|
||||
{
|
||||
@ -35,7 +35,7 @@ export const baseRoutes: Routes = [
|
||||
component: RoomCreatorComponent,
|
||||
canActivate: [checkUserAuthenticatedGuard],
|
||||
data: {
|
||||
expectedRoles: [Role.USER],
|
||||
expectedRoles: [UserRole.USER],
|
||||
redirectToUnauthorized: 'login',
|
||||
redirectToInvalidRole: 'console'
|
||||
}
|
||||
@ -59,7 +59,7 @@ export const baseRoutes: Routes = [
|
||||
component: ConsoleComponent,
|
||||
canActivate: [checkUserAuthenticatedGuard],
|
||||
data: {
|
||||
expectedRoles: [Role.ADMIN],
|
||||
expectedRoles: [UserRole.ADMIN],
|
||||
redirectToUnauthorized: 'console/login',
|
||||
redirectToInvalidRole: ''
|
||||
},
|
||||
|
||||
@ -3,7 +3,7 @@ import { HttpService } from '../http/http.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { from, Observable } from 'rxjs';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { Role, User } from '@lib/typings/ce';
|
||||
import { UserRole, User } from '@lib/typings/ce';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -60,7 +60,7 @@ export class AuthService {
|
||||
}
|
||||
|
||||
isAdmin(): boolean {
|
||||
return this.user?.role === Role.ADMIN;
|
||||
return this.user?.role === UserRole.ADMIN;
|
||||
}
|
||||
|
||||
private async getAuthenticatedUser() {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
export interface User {
|
||||
username: string;
|
||||
role: Role;
|
||||
role: UserRole;
|
||||
}
|
||||
|
||||
export const enum Role {
|
||||
export const enum UserRole {
|
||||
ADMIN = 'admin',
|
||||
USER = 'user'
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user