backend: Add comments in middlewares for clarity
This commit is contained in:
parent
93048f236a
commit
d10e6ea519
@ -4,6 +4,13 @@ import { container } from '../config/dependency-injector.config.js';
|
||||
import { GlobalPreferencesService, LoggerService, RoomService } from '../services/index.js';
|
||||
import { allowAnonymous, tokenAndRoleValidator, withAuth } from './auth.middleware.js';
|
||||
|
||||
/**
|
||||
* Middleware to configure authentication based on participant role and authentication mode for entering a room.
|
||||
*
|
||||
* - If the authentication mode is MODERATORS_ONLY and the participant role is MODERATOR, configure user authentication.
|
||||
* - If the authentication mode is ALL_USERS, configure user authentication.
|
||||
* - Otherwise, allow anonymous access.
|
||||
*/
|
||||
export const configureTokenAuth = async (req: Request, res: Response, next: NextFunction) => {
|
||||
const logger = container.get(LoggerService);
|
||||
const globalPrefService = container.get(GlobalPreferencesService);
|
||||
|
||||
@ -5,6 +5,13 @@ import { GlobalPreferencesService } from '../services/index.js';
|
||||
import { allowAnonymous, apiKeyValidator, tokenAndRoleValidator, withAuth } from './auth.middleware.js';
|
||||
import { AuthMode, ParticipantRole, UserRole } from '@typings-ce';
|
||||
|
||||
/**
|
||||
* Middleware that configures authentication for creating a room based on global settings.
|
||||
*
|
||||
* - Admin role and API key authentication methods are always allowed.
|
||||
* - If room creation is allowed and requires authentication, the user must have a valid token.
|
||||
* - If room creation is allowed and does not require authentication, anonymous users are allowed.
|
||||
*/
|
||||
export const configureCreateRoomAuth = async (req: Request, res: Response, next: NextFunction) => {
|
||||
const logger = container.get(LoggerService);
|
||||
const globalPrefService = container.get(GlobalPreferencesService);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user