Skip to content

Commit

Permalink
Add: toastify toast after redirect to login
Browse files Browse the repository at this point in the history
  • Loading branch information
MTraveller committed Oct 23, 2022
1 parent 43f3a65 commit 9dab71f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/PrivateRoute.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { navigate } from 'gatsby';
import { toast } from 'react-toastify';
import { isLoggedIn } from '../services/authService';

// Private route from Gatsby's
Expand All @@ -8,6 +9,7 @@ import { isLoggedIn } from '../services/authService';
const PrivateRoute = ({ component: Component, location, ...rest }) => {
if (!isLoggedIn() && location.pathname !== `/`) {
navigate('/');
toast('Please login, to continue.');
return null;
}

Expand Down

0 comments on commit 9dab71f

Please sign in to comment.