feat(backend): Endpoints voor studenten beschermd
This commit is contained in:
parent
bc60c18938
commit
6cb8a1b98f
7 changed files with 93 additions and 52 deletions
10
backend/src/middleware/auth/checks/user-auth-checks.ts
Normal file
10
backend/src/middleware/auth/checks/user-auth-checks.ts
Normal 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
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue