Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Greatly reduce repeated code
- Loading branch information
Showing
34 changed files
with
197 additions
and
482 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { jsonError } from "../../common.js"; | ||
|
||
export async function onRequest(context: RequestContext) { | ||
if (!context.data.current_user) | ||
return new Response('{"error":"Not logged in"}', { | ||
headers: { | ||
"content-type": "application/json", | ||
}, | ||
status: 401, | ||
}); | ||
if (!context.data.current_user) return jsonError("Not logged in", 401); | ||
|
||
return await context.next(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
import { jsonError } from "../../../common.js"; | ||
|
||
export async function onRequest(context: RequestContext) { | ||
if ( | ||
![1 << 3, 1 << 4, 1 << 12].find( | ||
(int) => context.data.current_user?.permissions & int, | ||
) | ||
) | ||
return new Response('{"error":"Forbidden"}', { | ||
headers: { | ||
"content-type": "application/json", | ||
}, | ||
status: 401, | ||
}); | ||
return jsonError("Forbidden", 403); | ||
|
||
return await context.next(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import { jsonError } from "../../../common.js"; | ||
|
||
export async function onRequest(context: RequestContext) { | ||
if ( | ||
![1 << 4, 1 << 12].find((p) => context.data.current_user?.permissions & p) | ||
) | ||
return new Response('{"error":"Forbidden"}', { | ||
headers: { | ||
"content-type": "application/json", | ||
}, | ||
status: 403, | ||
}); | ||
return jsonError("Forbidden", 403); | ||
|
||
return await context.next(); | ||
} |
Oops, something went wrong.