feat: teacher invitation middelware + extra error catchings
This commit is contained in:
parent
ac399153b6
commit
f671341bad
4 changed files with 43 additions and 5 deletions
|
@ -0,0 +1,23 @@
|
|||
import {authorize} from "./auth-checks";
|
||||
import {AuthenticationInfo} from "../authentication-info";
|
||||
import {AuthenticatedRequest} from "../authenticated-request";
|
||||
|
||||
export const onlyAllowSenderOrReceiver = authorize(
|
||||
(auth: AuthenticationInfo, req: AuthenticatedRequest) =>
|
||||
req.params.sender === auth.username || req.params.receiver === auth.username
|
||||
);
|
||||
|
||||
export const onlyAllowSender = authorize(
|
||||
(auth: AuthenticationInfo, req: AuthenticatedRequest) =>
|
||||
req.params.sender === auth.username
|
||||
);
|
||||
|
||||
export const onlyAllowSenderBody = authorize(
|
||||
(auth: AuthenticationInfo, req: AuthenticatedRequest) =>
|
||||
req.body.sender === auth.username
|
||||
);
|
||||
|
||||
export const onlyAllowReceiverBody = authorize(
|
||||
(auth: AuthenticationInfo, req: AuthenticatedRequest) =>
|
||||
req.body.receiver === auth.username
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue