Skip to content

Commit db46a0a

Browse files
author
Steve Hobbs
authored
Auth0 SDK redirect handler fix (#177)
* Callback handler checks for state in url as well as code * Updated dependencies
1 parent 1df6164 commit db46a0a

4 files changed

Lines changed: 3371 additions & 2856 deletions

File tree

01-Login/src/react-auth0-spa.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useState, useEffect, useContext } from "react";
22
import createAuth0Client from "@auth0/auth0-spa-js";
33

4-
54
const DEFAULT_REDIRECT_CALLBACK = () =>
65
window.history.replaceState({}, document.title, window.location.pathname);
76

@@ -23,7 +22,10 @@ export const Auth0Provider = ({
2322
const auth0FromHook = await createAuth0Client(initOptions);
2423
setAuth0(auth0FromHook);
2524

26-
if (window.location.search.includes("code=")) {
25+
if (
26+
window.location.search.includes("code=") &&
27+
window.location.search.includes("state=")
28+
) {
2729
const { appState } = await auth0FromHook.handleRedirectCallback();
2830
onRedirectCallback(appState);
2931
}

0 commit comments

Comments
 (0)