generated from BloomTech-Labs/asylum-rg-fe
-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from JaDa757/testing
Testing
- Loading branch information
Showing
15 changed files
with
4,322 additions
and
27,078 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import { useAuth0 } from '@auth0/auth0-react'; | ||
|
||
const Login = () => { | ||
const { loginWithRedirect } = useAuth0(); | ||
return ( | ||
<button | ||
style={{ | ||
color: '#E2F0F7', | ||
paddingRight: '75px', | ||
background: 'none', | ||
border: 'none', | ||
font: 'inherit', | ||
cursor: 'pointer', | ||
|
||
}} | ||
className="btn btn-primary btn-block" | ||
onClick={() => loginWithRedirect()} | ||
> | ||
Log In | ||
</button > | ||
|
||
); | ||
}; | ||
|
||
export default Login; |
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,29 @@ | ||
import React from 'react'; | ||
import { useAuth0 } from '@auth0/auth0-react'; | ||
|
||
const Logout = () => { | ||
const { logout } = useAuth0(); | ||
return ( | ||
<button | ||
style={{ | ||
color: '#E2F0F7', | ||
paddingRight: '75px', | ||
background: 'none', | ||
border: 'none', | ||
font: 'inherit', | ||
cursor: 'pointer', | ||
|
||
}} | ||
className="btn btn-danger btn-block" | ||
onClick={() => | ||
logout({ | ||
returnTo: window.location.origin, | ||
}) | ||
} | ||
> | ||
Log Out | ||
</button> | ||
); | ||
}; | ||
|
||
export default Logout; |
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,33 @@ | ||
import React from 'react'; | ||
|
||
import { useAuth0 } from '@auth0/auth0-react'; | ||
|
||
const Profile = () => { | ||
const { user } = useAuth0(); | ||
const { name, picture, email } = user; | ||
|
||
return ( | ||
<div> | ||
<div className="row align-items-center profile-header"> | ||
<div className="col-md-2 mb-3"> | ||
<img | ||
src={picture} | ||
alt="Profile" | ||
className="rounded-circle img-fluid profile-picture mb-3 mb-md-0" | ||
/> | ||
</div> | ||
<div className="col-md text-center text-md-left"> | ||
<h2>{name}</h2> | ||
<p className="lead text-muted">{email}</p> | ||
</div> | ||
</div> | ||
<div className="row"> | ||
<pre className="col-12 text-light bg-dark p-4"> | ||
{JSON.stringify(user, null, 2)} | ||
</pre> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Profile; |
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,29 @@ | ||
import React from 'react'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { Auth0Provider } from '@auth0/auth0-react'; | ||
|
||
const Auth0ProviderWithHistory = ({ children }) => { | ||
const domain = process.env.REACT_APP_AUTH0_DOMAIN; | ||
const clientId = process.env.REACT_APP_AUTH0_CLIENT_ID; | ||
|
||
|
||
|
||
const history = useHistory(); | ||
|
||
const onRedirectCallback = (appState) => { | ||
history.push(appState?.returnTo || window.location.pathname); | ||
}; | ||
|
||
return ( | ||
<Auth0Provider | ||
domain={domain} | ||
clientId={clientId} | ||
redirectUri={window.location.origin} | ||
onRedirectCallback={onRedirectCallback} | ||
> | ||
{children} | ||
</Auth0Provider> | ||
); | ||
}; | ||
|
||
export default Auth0ProviderWithHistory; |
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,15 @@ | ||
import React from 'react'; | ||
|
||
import Login from './Login'; | ||
import Logout from './Logout'; | ||
|
||
|
||
import { useAuth0 } from '@auth0/auth0-react'; | ||
|
||
const AuthButton = () => { | ||
const { isAuthenticated } = useAuth0(); | ||
|
||
return isAuthenticated ? <Logout /> : <Login />; | ||
}; | ||
|
||
export default AuthButton; |
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
Oops, something went wrong.