@@ -5,7 +5,7 @@ import {parseSearchParamsToObject} from '$lib/utils/index.js';
5
5
import type { SessionManager } from '@kinde-oss/kinde-typescript-sdk' ;
6
6
import { error , redirect , type RequestEvent } from '@sveltejs/kit' ;
7
7
8
- const KEY_POST_REDIRECT_URL = 'post-redirect-url' ;
8
+ const KEY_POST_LOGIN_REDIRECT_URL = 'post-login -redirect-url' ;
9
9
10
10
export async function handleAuth ( {
11
11
request,
@@ -16,11 +16,11 @@ export async function handleAuth({
16
16
let url : URL | null = null ;
17
17
switch ( params . kindeAuth ) {
18
18
case 'login' :
19
- storePostRedirectUrl ( options ) ;
19
+ storePostLoginRedirectUrl ( options ) ;
20
20
url = await kindeAuthClient . login ( request as unknown as SessionManager , options ) ;
21
21
break ;
22
22
case 'register' :
23
- storePostRedirectUrl ( options ) ;
23
+ storePostLoginRedirectUrl ( options ) ;
24
24
url = await kindeAuthClient . register ( request as unknown as SessionManager , options ) ;
25
25
break ;
26
26
case 'create_org' :
@@ -31,7 +31,7 @@ export async function handleAuth({
31
31
request as unknown as SessionManager ,
32
32
new URL ( request . url )
33
33
) ;
34
- redirectToPostUrl ( ) ;
34
+ redirectToPostLoginUrl ( ) ;
35
35
throw redirect ( 302 , kindeConfiguration . loginRedirectURL ?? '/' ) ;
36
36
case 'logout' :
37
37
url = await kindeAuthClient . logout ( request as unknown as SessionManager ) ;
@@ -42,16 +42,16 @@ export async function handleAuth({
42
42
throw redirect ( 302 , url . toString ( ) ) ;
43
43
}
44
44
45
- const storePostRedirectUrl = ( options : Record < string , string | number > ) => {
46
- if ( options . post_redirect_url && typeof options . post_redirect_url == 'string' ) {
47
- sessionStorage . setSessionItem ( KEY_POST_REDIRECT_URL , options . post_redirect_url ) ;
45
+ const storePostLoginRedirectUrl = ( options : Record < string , string | number > ) => {
46
+ if ( options . post_login_redirect_url && typeof options . post_login_redirect_url == 'string' ) {
47
+ sessionStorage . setSessionItem ( KEY_POST_LOGIN_REDIRECT_URL , options . post_login_redirect_url ) ;
48
48
}
49
49
} ;
50
50
51
- const redirectToPostUrl = ( ) => {
52
- if ( sessionStorage . getSessionItem ( KEY_POST_REDIRECT_URL ) ) {
53
- const post_redirect_url = sessionStorage . getSessionItem ( KEY_POST_REDIRECT_URL ) ;
54
- sessionStorage . removeSessionItem ( KEY_POST_REDIRECT_URL ) ;
55
- throw redirect ( 302 , new URL ( post_redirect_url , kindeConfiguration . appBase ) ) ;
51
+ const redirectToPostLoginUrl = ( ) => {
52
+ if ( sessionStorage . getSessionItem ( KEY_POST_LOGIN_REDIRECT_URL ) ) {
53
+ const post_login_redirect_url = sessionStorage . getSessionItem ( KEY_POST_LOGIN_REDIRECT_URL ) ;
54
+ sessionStorage . removeSessionItem ( KEY_POST_LOGIN_REDIRECT_URL ) ;
55
+ throw redirect ( 302 , new URL ( post_login_redirect_url , kindeConfiguration . appBase ) ) ;
56
56
}
57
57
} ;
0 commit comments