Fixed redirect issue
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { useContext, useRef } from 'react';
|
||||
import { Link, Navigate } from 'react-router-dom';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
|
||||
import ApplyToBody from '../utilities/apply-to-body';
|
||||
|
||||
@@ -9,12 +9,15 @@ import { TokenContext } from '../utilities/token-provider';
|
||||
const validateEmail = require('../../../common/utilities/validate-email');
|
||||
|
||||
const Recover = props => {
|
||||
//history
|
||||
const navigate = useNavigate();
|
||||
|
||||
//context
|
||||
const authTokens = useContext(TokenContext);
|
||||
|
||||
//misplaced?
|
||||
if (authTokens.accessToken) {
|
||||
return <Navigate to='/' />;
|
||||
navigate("/");
|
||||
}
|
||||
|
||||
//refs
|
||||
@@ -39,7 +42,7 @@ const Recover = props => {
|
||||
|
||||
//redirect
|
||||
if (redirect) {
|
||||
props.history.push('/');
|
||||
navigate("/");
|
||||
}
|
||||
}
|
||||
}>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useContext, useRef } from 'react';
|
||||
import { Link, Navigate } from 'react-router-dom';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import queryString from 'query-string';
|
||||
|
||||
import ApplyToBody from '../utilities/apply-to-body';
|
||||
@@ -7,6 +7,9 @@ import ApplyToBody from '../utilities/apply-to-body';
|
||||
import { TokenContext } from '../utilities/token-provider';
|
||||
|
||||
const Reset = props => {
|
||||
//history
|
||||
const navigate = useNavigate();
|
||||
|
||||
//context
|
||||
const authTokens = useContext(TokenContext);
|
||||
|
||||
@@ -15,7 +18,7 @@ const Reset = props => {
|
||||
|
||||
//misplaced?
|
||||
if (authTokens.accessToken || !query.email || !query.token) {
|
||||
return <Navigate to='/' />;
|
||||
navigate("/");
|
||||
}
|
||||
|
||||
//refs
|
||||
@@ -42,7 +45,7 @@ const Reset = props => {
|
||||
|
||||
//redirect
|
||||
if (redirect) {
|
||||
props.history.push('/');
|
||||
navigate("/");
|
||||
}
|
||||
}}>
|
||||
<input type='password' name='password' placeholder='New Password' ref={passwordRef} />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useContext, useRef } from 'react';
|
||||
import { Link, Navigate } from 'react-router-dom';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
|
||||
import ApplyToBody from '../utilities/apply-to-body';
|
||||
|
||||
@@ -10,12 +10,15 @@ const validateEmail = require('../../../common/utilities/validate-email');
|
||||
const validateUsername = require('../../../common/utilities/validate-username');
|
||||
|
||||
const Signup = props => {
|
||||
//history
|
||||
const navigate = useNavigate();
|
||||
|
||||
//context
|
||||
const authTokens = useContext(TokenContext);
|
||||
|
||||
//misplaced?
|
||||
if (authTokens.accessToken) {
|
||||
return <Navigate to='/' />;
|
||||
navigate("/");
|
||||
}
|
||||
|
||||
//refs
|
||||
@@ -44,7 +47,7 @@ const Signup = props => {
|
||||
|
||||
//redirect
|
||||
if (redirect) {
|
||||
props.history.push('/');
|
||||
navigate("/");
|
||||
}
|
||||
}
|
||||
}>
|
||||
|
||||
Reference in New Issue
Block a user