Adds authentication

This commit is contained in:
Rob Cameron
2020-10-07 14:45:51 -07:00
parent 35456b0a4d
commit 2941c967ad
8 changed files with 189 additions and 9 deletions

View File

@@ -1,6 +1,9 @@
import { Link,routes } from '@redwoodjs/router'
import { Link, routes } from '@redwoodjs/router'
import { useAuth } from '@redwoodjs/auth'
const BlogLayout = ({ children }) => {
const { logIn, logOut, isAuthenticated, currentUser } = useAuth()
return (
<>
<header>
@@ -15,6 +18,12 @@ const BlogLayout = ({ children }) => {
<li>
<Link to={routes.contact()}>Contact</Link>
</li>
<li>
<a href="#" onClick={isAuthenticated ? logOut : logIn}>
{isAuthenticated ? 'Log Out' : 'Log In'}
</a>
</li>
{isAuthenticated && <li>{currentUser.email}</li>}
</ul>
</nav>
</header>