-
Notifications
You must be signed in to change notification settings - Fork 1
Auth0 for authorization and authentication #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,11 +5,22 @@ import App from './App'; | |
| import 'core-js/stable'; | ||
| import 'regenerator-runtime/runtime'; | ||
|
|
||
| //for Auth0 | ||
| import { Auth0Provider } from "@auth0/auth0-react"; | ||
| import LoginButton from './login'; | ||
|
|
||
|
|
||
| const container = document.getElementById('root'); | ||
| const root = createRoot(container); | ||
|
|
||
| root.render( | ||
| <React.StrictMode> | ||
| <App /> | ||
| </React.StrictMode> | ||
| <Auth0Provider | ||
| domain="dev-gi520dy8.us.auth0.com" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are these ok to go into public repository, or should they be part of the |
||
| clientId="LUsIqguU5pbiZ7fWzz2AQKcLZ91luUEt" | ||
| redirectUri={window.location.origin} | ||
| > | ||
| <App /> | ||
| </Auth0Provider> | ||
| </React.StrictMode> | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { useAuth0 } from "@auth0/auth0-react"; | ||
| import React from "react"; | ||
|
|
||
| const LoginButton = () => { | ||
| const { loginWithRedirect } = useAuth0(); | ||
|
|
||
| return <button onClick={() => loginWithRedirect()}>Log In</button>; | ||
| }; | ||
|
|
||
| export default LoginButton; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { useAuth0 } from "@auth0/auth0-react"; | ||
| import React from "react"; | ||
|
|
||
| const LogoutButton = () => { | ||
| const { logout } = useAuth0(); | ||
|
|
||
| return ( | ||
| <button onClick={() => logout({ returnTo: window.location.origin })}> | ||
| Log Out | ||
| </button> | ||
| ); | ||
| }; | ||
|
|
||
| export default LogoutButton; |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the way most websites are, I think, is what users will expect:
I guess let's think of Google itself as the template for how people expect these to work?
I think most of this can be done pretty easily within the bootstrap framework. The auto-redirect thing is also abstracted by something like this:
https://github.com/jaredhanson/connect-ensure-login
and I had a few more links to useful things on the ticket #3