-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from msisaifu/route-gurads
Route gurads
- Loading branch information
Showing
14 changed files
with
190 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import routes from './routes' | ||
|
||
function Authenticate(pathname, user_role) { | ||
for (const section in routes) { | ||
for (const sub_section in routes[section]) { | ||
const route = routes[section][sub_section] | ||
const route_access = route['access'] | ||
const pattern = new RegExp(`^/${section}${route.path}`, 'i') | ||
if (pattern.test(pathname + '/') && route_access.includes(user_role)) { | ||
return true | ||
} | ||
} | ||
} | ||
return false | ||
} | ||
|
||
export { Authenticate } |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const user_contexts = ['*'] | ||
const admin_contexts = ['admin'] | ||
|
||
const routes = { | ||
admin: [ | ||
{ path: '/admins', access: admin_contexts }, | ||
{ path: '/channels', access: admin_contexts }, | ||
{ path: '/fun-facts', access: admin_contexts }, | ||
{ path: '/fun-facts', access: admin_contexts }, | ||
{ path: '/legal', access: admin_contexts }, | ||
{ path: '/settings', access: admin_contexts }, | ||
{ path: '/users', access: admin_contexts } | ||
], | ||
browse: [ | ||
{ path: '/', access: user_contexts }, | ||
{ path: '/(.*)/$', access: user_contexts } | ||
], | ||
channel: [ | ||
{ path: '/', access: user_contexts }, | ||
{ path: '/(.*)/$', access: user_contexts } | ||
], | ||
profile: [ | ||
{ path: '/', access: admin_contexts }, | ||
{ path: '/(.*)/$', access: admin_contexts } | ||
], | ||
search: [ | ||
{ path: '/', access: user_contexts }, | ||
{ path: '/(.*)/', access: user_contexts } | ||
], | ||
maintenance: [{ path: '/', access: user_contexts }], | ||
settings: [{ path: '/', access: user_contexts }], | ||
premium: [{ path: '/', access: admin_contexts }], | ||
careers: [{ path: '/', access: user_contexts }], | ||
contact: [{ path: '/', access: user_contexts }], | ||
videos: [{ path: '/', access: user_contexts }], | ||
legal: [{ path: '/', access: user_contexts }], | ||
logout: [{ path: '/', access: admin_contexts }], | ||
'creator-space': [{ path: '/', access: user_contexts }] | ||
} | ||
|
||
export default routes |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { error } from '@sveltejs/kit' | ||
import type { PageServerLoad } from './$types' | ||
|
||
export const load = (async ({ params }) => { | ||
// const post = null | ||
// if (post) { | ||
// return post | ||
// } | ||
// throw error(404, 'Not found') | ||
}) satisfies PageServerLoad |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { error } from '@sveltejs/kit' | ||
import type { PageServerLoad } from './$types' | ||
|
||
export const load = (async ({ params }) => { | ||
// const post = null | ||
// if (post) { | ||
// return post | ||
// } | ||
// throw error(404, 'Not found') | ||
}) satisfies PageServerLoad |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { error } from '@sveltejs/kit' | ||
import type { PageServerLoad } from './$types' | ||
|
||
export const load = (async ({ params }) => { | ||
// const post = null | ||
// if (post) { | ||
// return post | ||
// } | ||
// throw error(404, 'Not found') | ||
}) satisfies PageServerLoad |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { error } from '@sveltejs/kit' | ||
import type { PageServerLoad } from './$types' | ||
|
||
export const load = (async ({ params }) => { | ||
// const post = null | ||
// if (post) { | ||
// return post | ||
// } | ||
// throw error(404, 'Not found') | ||
}) satisfies PageServerLoad |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { error } from '@sveltejs/kit' | ||
import type { PageServerLoad } from './$types' | ||
|
||
export const load = (async ({ params }) => { | ||
// const post = null | ||
// if (post) { | ||
// return post | ||
// } | ||
// throw error(404, 'Not found') | ||
}) satisfies PageServerLoad |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { error } from '@sveltejs/kit' | ||
import type { PageServerLoad } from './$types' | ||
|
||
export const load = (async ({ params }) => { | ||
// const post = null | ||
// if (post) { | ||
// return post | ||
// } | ||
// throw error(404, 'Not found') | ||
}) satisfies PageServerLoad |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { error } from '@sveltejs/kit' | ||
import type { PageServerLoad } from './$types' | ||
|
||
export const load = (async ({ params }) => { | ||
// const post = null | ||
// if (post) { | ||
// return post | ||
// } | ||
// throw error(404, 'Not found') | ||
}) satisfies PageServerLoad |
Empty file.
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
Empty file.