Exercise 10: Protected Routes
We will run and verify our app after the implementation of Protected Routes.
We'll cover the following...
We'll cover the following...
Project
import React from 'react';
import { AuthUserContext } from '../Session';
import { PasswordForgetForm } from '../PasswordForget';
import PasswordChangeForm from '../PasswordChange';
import { withAuthorization } from '../Session';
const AccountPage = () => (
<AuthUserContext.Consumer>
{authUser => (
<div>
<h1>Account: {authUser.email}</h1>
<PasswordForgetForm />
<PasswordChangeForm />
</div>
)}
</AuthUserContext.Consumer>
);
const authCondition = authUser => !!authUser;
export default withAuthorization(authCondition)(AccountPage);
Now, all the user-specific routes are protected. Without signing in, we cannot access a protected page such as Home or Landing.
If we try replacing the ...