2025SELab2-project-Dwengo/backend/src/middleware/auth/checks/user-auth-checks.ts
2025-05-15 20:52:47 +02:00

8 lines
428 B
TypeScript

import { authorize } from './auth-checks.js';
import { AuthenticationInfo } from '../authentication-info.js';
import { AuthenticatedRequest } from '../authenticated-request.js';
/**
* Only allow the user whose username is in the path parameter "username" to access the endpoint.
*/
export const preventImpersonation = authorize((auth: AuthenticationInfo, req: AuthenticatedRequest) => req.params.username === auth.username);