@@ -38,7 +38,7 @@ import { KindeContext, KindeContextProps } from "./KindeContext";
38
38
import { getRedirectUrl } from "../utils/getRedirectUrl" ;
39
39
import packageJson from "../../package.json" ;
40
40
import { ErrorProps , LogoutOptions } from "./types" ;
41
- import { RefreshTokenResult } from "@kinde/js-utils/dist/utils/token/refreshToken " ;
41
+ import { RefreshTokenResult } from "@kinde/js-utils" ;
42
42
// TODO: need to look for old token store and convert.
43
43
storageSettings . keyPrefix = "" ;
44
44
@@ -168,6 +168,7 @@ export const KindeProvider = ({
168
168
audience,
169
169
clientId,
170
170
...options ,
171
+ supportsReauth : true ,
171
172
state : base64UrlEncode (
172
173
JSON . stringify ( {
173
174
kinde : { event : AuthEvent . login } ,
@@ -207,6 +208,7 @@ export const KindeProvider = ({
207
208
...optionsState ,
208
209
} ) ,
209
210
) ,
211
+ supportsReauth : true ,
210
212
audience : ( await storeState . memoryStorage . getSessionItem (
211
213
storeState . LocalKeys . audience ,
212
214
) ) as string ,
@@ -402,7 +404,22 @@ export const KindeProvider = ({
402
404
const params = new URLSearchParams ( window . location . search ) ;
403
405
let returnedState : StateWithKinde ;
404
406
let kindeState : KindeState ;
405
- if ( ! params . has ( "code" ) ) {
407
+
408
+ if ( params . has ( "error" ) ) {
409
+ const errorCode = params . get ( "error" ) ;
410
+ if ( errorCode ?. toLowerCase ( ) === "login_link_expired" ) {
411
+ const reauthState = params . get ( "reauth_state" ) ;
412
+ if ( reauthState ) {
413
+ login ( { reauthState : reauthState } ) ;
414
+ }
415
+ return ;
416
+ }
417
+ setState ( ( val : ProviderState ) => ( { ...val , isLoading : false } ) ) ;
418
+ return ;
419
+ }
420
+
421
+ const hasCode = params . has ( "code" ) ;
422
+ if ( ! hasCode ) {
406
423
try {
407
424
const user = await getUserProfile ( ) ;
408
425
if ( user ) {
0 commit comments