-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNoAccess.js
52 lines (42 loc) · 1.48 KB
/
NoAccess.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import {Link} from 'react-router-dom'
import { useMoralis } from "react-moralis";
import Button from '../components/Button'
import './About.css';
//page that handles when a user tries to access a page they should not be on due to not being authenticated
function NoAccess() {
// The useMoralis hook provides all the basics functionalities that is needed for authentication and user data.
const { authenticate, isAuthenticated, logout, user } = useMoralis();
return(
<div className='about-page-container'>
<div className='header display-inline'>
{/* {check if user is already connected} */}
{isAuthenticated ?
// if true show:
<>
<>
<div className='back-btn'>
<Link to= '/'> <Button text={'Back'}/> </Link>
</div>
</>
<>
<small>{user.get("ethAddress")}</small>
<Button text={'Logout'} onClick ={logout}/>
</>
</>
:
// if false show:
<>
<Link to= '/'> <Button text={'Back'}/> </Link>
<Button text={'Connect Wallet'} onClick ={() => authenticate({ provider: "metamask" })}/>
</>
}
</div>
<div className='about-body-container'>
<div className='left-about'>
No Access to this page, please connect wallet or go back to the home page
</div>
</div>
</div>
);
}
export default NoAccess;