feat: login wall (#42)
* feat: add login-wall app * fix: rename vars * fix: rename vars * update docker file * add validations for app state * add host check for app * fix: docker file
This commit is contained in:
52
app/src/pages/dashboard.tsx
Normal file
52
app/src/pages/dashboard.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import React from 'react';
|
||||
import { useAuthorizer } from '@authorizerdev/authorizer-react';
|
||||
|
||||
export default function Dashboard() {
|
||||
const [loading, setLoading] = React.useState(false);
|
||||
const { user, setToken, graphQlRef } = useAuthorizer();
|
||||
|
||||
const onLogout = async () => {
|
||||
setLoading(true);
|
||||
await graphQlRef
|
||||
.mutation(
|
||||
`
|
||||
mutation {
|
||||
logout {
|
||||
message
|
||||
}
|
||||
}
|
||||
`
|
||||
)
|
||||
.toPromise();
|
||||
setToken(null);
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Hey 👋,</h1>
|
||||
<p>Thank you for joining authorizer demo app.</p>
|
||||
<p>
|
||||
Your email address is{' '}
|
||||
<a href={`mailto:${user?.email}`} style={{ color: '#3B82F6' }}>
|
||||
{user?.email}
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<br />
|
||||
{loading ? (
|
||||
<h3>Processing....</h3>
|
||||
) : (
|
||||
<h3
|
||||
style={{
|
||||
color: '#3B82F6',
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
onClick={onLogout}
|
||||
>
|
||||
Logout
|
||||
</h3>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
10
app/src/pages/login.tsx
Normal file
10
app/src/pages/login.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import { Authorizer } from '@authorizerdev/authorizer-react';
|
||||
|
||||
export default function Login() {
|
||||
return (
|
||||
<Fragment>
|
||||
<Authorizer />
|
||||
</Fragment>
|
||||
);
|
||||
}
|
12
app/src/pages/rest-password.tsx
Normal file
12
app/src/pages/rest-password.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import { AuthorizerResetPassword } from '@authorizerdev/authorizer-react';
|
||||
|
||||
export default function ResetPassword() {
|
||||
return (
|
||||
<Fragment>
|
||||
<h1 style={{ textAlign: 'center' }}>Reset Password</h1>
|
||||
<br />
|
||||
<AuthorizerResetPassword />
|
||||
</Fragment>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user