Skip to content

Commit 4b3bb21

Browse files
author
Steve Hobbs
authored
Refactored usage of redirect_uri (#126)
* Refactored usage of redirect_uri Moved the redirect_uri assigment to the creation of the Auth0Provider so that it doesn't have to be specified everywhere `loginWithRedirect` is used. * Removed redirect_uri from PrivateRoute
1 parent 963b692 commit 4b3bb21

6 files changed

Lines changed: 4 additions & 12 deletions

File tree

01-Login/src/components/NavBar.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ const NavBar = () => {
5858
id="qsLoginBtn"
5959
color="primary"
6060
className="btn-margin"
61-
onClick={() =>
62-
loginWithRedirect({
63-
redirect_uri: window.location.origin
64-
})
65-
}
61+
onClick={() => loginWithRedirect({})}
6662
>
6763
Log in
6864
</Button>

01-Login/src/components/PrivateRoute.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const PrivateRoute = ({ component: Component, path, ...rest }) => {
1010
const fn = async () => {
1111
if (!isAuthenticated) {
1212
await loginWithRedirect({
13-
redirect_uri: window.location.origin,
1413
appState: { targetUrl: path }
1514
});
1615
}

01-Login/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ReactDOM.render(
2020
<Auth0Provider
2121
domain={config.domain}
2222
client_id={config.clientId}
23+
redirect_uri={window.location.origin}
2324
onRedirectCallback={onRedirectCallback}
2425
>
2526
<App />

02-Calling-an-API/src/components/NavBar.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ const NavBar = () => {
7070
id="qsLoginBtn"
7171
color="primary"
7272
className="btn-margin"
73-
onClick={() =>
74-
loginWithRedirect({
75-
redirect_uri: window.location.origin
76-
})
77-
}
73+
onClick={() => loginWithRedirect({})}
7874
>
7975
Log in
8076
</Button>

02-Calling-an-API/src/components/PrivateRoute.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const PrivateRoute = ({ component: Component, path, ...rest }) => {
1010
const fn = async () => {
1111
if (!isAuthenticated) {
1212
await loginWithRedirect({
13-
redirect_uri: window.location.origin,
1413
appState: { targetUrl: path }
1514
});
1615
}

02-Calling-an-API/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ ReactDOM.render(
2121
domain={config.domain}
2222
client_id={config.clientId}
2323
audience={config.audience}
24+
redirect_uri={window.location.origin}
2425
onRedirectCallback={onRedirectCallback}
2526
>
2627
<App />

0 commit comments

Comments
 (0)