WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit fb4ccc9

Browse files
authored
🚀 Enhancement: Add 403 lockout for management pages (#284)
1 parent 3140fc1 commit fb4ccc9

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

messages/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@
438438
"newsletters": "Newsletter",
439439
"next": "Weiter",
440440
"no": "Nein",
441+
"noAccess": "Hier hast du keinen Zugriff",
441442
"noAnswer": "Keine Antwort",
442443
"noAnswerYet": "Noch nicht beantwortet",
443444
"noCommittees": "Keine Gremien",

messages/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@
438438
"newsletters": "Newsletter",
439439
"next": "Next",
440440
"no": "No",
441+
"noAccess": "You don't have access to this page.",
441442
"noAnswer": "No Answer",
442443
"noAnswerYet": "Not yet answered",
443444
"noCommittees": "No Committees",

src/routes/(authenticated)/management/+page.ts renamed to src/routes/(authenticated)/management/+layout.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { graphql } from '$houdini';
22
import { allConferenceQuery } from '$lib/queries/allConferences';
3-
import type { PageLoad } from './$types';
3+
import { error } from '@sveltejs/kit';
4+
import type { LayoutLoad } from './$types';
5+
import { m } from '$lib/paraglide/messages';
46

57
const conferencesWhereImMoreThanMember = graphql(`
68
query ConferencesWhereImMoreThanMember($myUserId: String!) {
@@ -28,7 +30,7 @@ const conferencesWhereImMoreThanMember = graphql(`
2830
}
2931
`);
3032

31-
export const load: PageLoad = async (event) => {
33+
export const load: LayoutLoad = async (event) => {
3234
const { user } = await event.parent();
3335

3436
// we want the conferences to appear either if we are a privileged user on that conference or
@@ -53,6 +55,11 @@ export const load: PageLoad = async (event) => {
5355
blocking: true
5456
});
5557
const queriedConfernces = data?.findManyConferences;
58+
59+
if (queriedConfernces.length === 0) {
60+
error(403, m.noAccess());
61+
}
62+
5663
return {
5764
conferences: queriedConfernces?.map((c) => ({
5865
id: c.id,

src/routes/(authenticated)/management/[conferenceId]/+layout.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
import { error } from '@sveltejs/kit';
12
import type { LayoutLoad } from './$types';
3+
import { m } from '$lib/paraglide/messages';
24

35
export const load: LayoutLoad = async (event) => {
6+
const parentData = await event.parent();
7+
8+
if (!parentData.conferences.map((c) => c.id).includes(event.params.conferenceId))
9+
error(403, m.noAccess());
10+
411
return {
512
conferenceId: event.params.conferenceId
613
};

0 commit comments

Comments
 (0)