Client - add password reset - #50

This commit is contained in:
Sam
2020-05-17 18:20:15 +02:00
parent 51d627fa1c
commit 1860cfe320
16 changed files with 348 additions and 83 deletions

View File

@ -1,3 +1,12 @@
const routesWithoutAuthentication = [
'/login',
'/register',
'/password-reset',
'/password-reset/request',
'/password-reset/sent',
'/updated-password',
]
const updatePath = (toPath, newPath) => {
if (typeof toPath === 'string' || toPath instanceof String) {
toPath = newPath
@ -10,13 +19,13 @@ const updatePath = (toPath, newPath) => {
const pathInterceptor = toPath => {
if (
!window.localStorage.authToken &&
!['/login', '/register'].includes(toPath.pathname)
!routesWithoutAuthentication.includes(toPath.pathname)
) {
toPath = updatePath(toPath, '/login')
}
if (
window.localStorage.authToken &&
['/login', '/register'].includes(toPath.pathname)
routesWithoutAuthentication.includes(toPath.pathname)
) {
toPath = updatePath(toPath, '/')
}