generated from hackforla/.github-hackforla-base-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
549 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
# Use to simulate different environments (DEV, UAT, PROD) | ||
REACT_APP_ENV=DEV | ||
|
||
REACT_APP_API_SERVER_URL=http://localhost:5001 | ||
REACT_APP_AUTH0_DOMAIN=dev-o7b5lcj02fchkh7t.us.auth0.com | ||
REACT_APP_AUTH0_CLIENT_ID=2yH0DY3x9a0qFjfXRKZCmguZDe8BM0dB | ||
REACT_APP_AUTH0_CALLBACK_URL=http://localhost:3000/callback | ||
REACT_APP_AUTH0_AUDIENCE=https://hello-world.example.com |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Auth0Provider } from "@auth0/auth0-react"; | ||
import PropTypes from "prop-types"; | ||
import React from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
const Auth0ProviderWithNavigate = ({ children }) => { | ||
const navigate = useNavigate(); | ||
|
||
const domain = process.env.REACT_APP_AUTH0_DOMAIN; | ||
const clientId = process.env.REACT_APP_AUTH0_CLIENT_ID; | ||
const redirectUri = process.env.REACT_APP_AUTH0_CALLBACK_URL; | ||
|
||
const onRedirectCallback = appState => { | ||
navigate(appState.returnTo || window.location.pathname); | ||
}; | ||
|
||
if (!(domain && clientId && redirectUri)) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Auth0Provider | ||
domain={domain} | ||
clientId={clientId} | ||
authorizationParams={{ | ||
redirect_uri: redirectUri | ||
}} | ||
onRedirectCallback={onRedirectCallback} | ||
> | ||
{children} | ||
</Auth0Provider> | ||
); | ||
}; | ||
|
||
Auth0ProviderWithNavigate.propTypes = { | ||
children: PropTypes.any | ||
}; | ||
|
||
export default Auth0ProviderWithNavigate; |
Oops, something went wrong.