2021-08-04 06:48:57 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { useAuthorizer } from '@authorizerdev/authorizer-react';
|
|
|
|
|
|
|
|
export default function Dashboard() {
|
2021-09-04 22:27:29 +00:00
|
|
|
const [loading, setLoading] = React.useState(false);
|
|
|
|
const { user, setToken, authorizerRef } = useAuthorizer();
|
2021-08-04 06:48:57 +00:00
|
|
|
|
2021-09-04 22:27:29 +00:00
|
|
|
const onLogout = async () => {
|
|
|
|
setLoading(true);
|
|
|
|
await authorizerRef.logout();
|
|
|
|
setToken(null);
|
|
|
|
setLoading(false);
|
|
|
|
};
|
2021-08-04 06:48:57 +00:00
|
|
|
|
2021-09-04 22:27:29 +00:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<h1>Hey 👋,</h1>
|
2022-01-25 07:36:52 +00:00
|
|
|
<p>Thank you for using authorizer.</p>
|
2021-09-04 22:27:29 +00:00
|
|
|
<p>
|
|
|
|
Your email address is{' '}
|
|
|
|
<a href={`mailto:${user?.email}`} style={{ color: '#3B82F6' }}>
|
|
|
|
{user?.email}
|
|
|
|
</a>
|
|
|
|
</p>
|
2021-08-04 06:48:57 +00:00
|
|
|
|
2021-09-04 22:27:29 +00:00
|
|
|
<br />
|
|
|
|
{loading ? (
|
|
|
|
<h3>Processing....</h3>
|
|
|
|
) : (
|
|
|
|
<h3
|
|
|
|
style={{
|
|
|
|
color: '#3B82F6',
|
|
|
|
cursor: 'pointer',
|
|
|
|
}}
|
|
|
|
onClick={onLogout}
|
|
|
|
>
|
|
|
|
Logout
|
|
|
|
</h3>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
2021-08-04 06:48:57 +00:00
|
|
|
}
|