-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove await from logout redirect * catch error when token is unparsable * move login redirect to parent layout to reduce redundant code
- Loading branch information
Showing
26 changed files
with
57 additions
and
192 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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import { base } from '$app/paths'; | ||
import { redirect } from '@sveltejs/kit'; | ||
import { shouldRedirectToLogin } from '../utilities/login'; | ||
import type { LayoutServerLoad } from './$types'; | ||
|
||
export const load: LayoutServerLoad = async ({ locals }) => { | ||
export const load: LayoutServerLoad = async ({ locals, url }) => { | ||
if (!url.pathname.includes('login') && shouldRedirectToLogin(locals.user)) { | ||
throw redirect(302, `${base}/login`); | ||
} | ||
return { ...locals }; | ||
}; |
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,14 +1,7 @@ | ||
import { base } from '$app/paths'; | ||
import { redirect } from '@sveltejs/kit'; | ||
import { shouldRedirectToLogin } from '../../utilities/login'; | ||
import type { PageLoad } from './$types'; | ||
|
||
export const load: PageLoad = async ({ parent }) => { | ||
const { user } = await parent(); | ||
|
||
if (shouldRedirectToLogin(user)) { | ||
throw redirect(302, `${base}/login`); | ||
} | ||
|
||
return { user }; | ||
}; |
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,14 +1,7 @@ | ||
import { base } from '$app/paths'; | ||
import { redirect } from '@sveltejs/kit'; | ||
import { shouldRedirectToLogin } from '../../../utilities/login'; | ||
import type { PageLoad } from './$types'; | ||
|
||
export const load: PageLoad = async ({ parent }) => { | ||
const { user } = await parent(); | ||
|
||
if (shouldRedirectToLogin(user)) { | ||
throw redirect(302, `${base}/login`); | ||
} | ||
|
||
return { user }; | ||
}; |
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,14 +1,7 @@ | ||
import { base } from '$app/paths'; | ||
import { redirect } from '@sveltejs/kit'; | ||
import { shouldRedirectToLogin } from '../../../../utilities/login'; | ||
import type { PageLoad } from './$types'; | ||
|
||
export const load: PageLoad = async ({ parent }) => { | ||
const { user } = await parent(); | ||
|
||
if (shouldRedirectToLogin(user)) { | ||
throw redirect(302, `${base}/login`); | ||
} | ||
|
||
return { user }; | ||
}; |
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,14 +1,7 @@ | ||
import { base } from '$app/paths'; | ||
import { redirect } from '@sveltejs/kit'; | ||
import { shouldRedirectToLogin } from '../../../utilities/login'; | ||
import type { PageLoad } from './$types'; | ||
|
||
export const load: PageLoad = async ({ parent }) => { | ||
const { user } = await parent(); | ||
|
||
if (shouldRedirectToLogin(user)) { | ||
throw redirect(302, `${base}/login`); | ||
} | ||
|
||
return { user }; | ||
}; |
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
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
Oops, something went wrong.