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