feat(backend): Endpoints voor studenten beschermd

This commit is contained in:
Gerald Schmittinger 2025-04-08 13:07:54 +02:00
parent bc60c18938
commit 6cb8a1b98f
7 changed files with 93 additions and 52 deletions

View file

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