Adds authentication
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user