Skip to content
Snippets Groups Projects

Greg 89 login redirect

Merged elg requested to merge GREG-89-login-redirect into master
4 files
+ 6
9
Compare changes
  • Side-by-side
  • Inline
Files
4
import React from 'react'
import { Route, Redirect, RouteProps, useLocation, useHistory } from 'react-router-dom'
import { Route, RouteProps, useLocation, useHistory } from 'react-router-dom'
import { setCookie } from 'utils'
import { useUserContext } from 'contexts'
@@ -13,8 +13,8 @@ function ProtectedRoute({ children, ...rest }: IProtectedRoute) {
const { user } = useUserContext()
if ( !user.auth ) {
let location = useLocation()
let history = useHistory()
const location = useLocation()
const history = useHistory()
setCookie('redirect', location.pathname)
history.push('/')
}
Loading