Fix unauthenticated redirects

This commit is contained in:
Robert Long 2021-11-19 10:47:40 -08:00
parent e438d85018
commit 7610226975
4 changed files with 32 additions and 4 deletions

View File

@ -18,6 +18,7 @@
"react": "^17.0.0",
"react-dom": "^17.0.0",
"react-json-view": "^1.21.3",
"react-router": "6",
"react-router-dom": "^5.2.0"
},
"devDependencies": {

View File

@ -16,7 +16,7 @@ limitations under the License.
import React from "react";
import {
HashRouter as Router,
BrowserRouter as Router,
Switch,
Route,
Redirect,

View File

@ -1,10 +1,12 @@
import React, { useEffect } from "react";
import { Center, Content, Modal } from "./Layout";
import { Link } from "react-router-dom";
import { Link, useLocation } from "react-router-dom";
import { ErrorMessage } from "./Input";
import styles from "./ErrorModal.module.css";
export function ErrorModal({ error }) {
const location = useLocation();
useEffect(() => {
console.error(error);
}, [error]);
@ -17,10 +19,14 @@ export function ErrorModal({ error }) {
<div className={styles.errorModalContent}>
<ErrorMessage>{error.message}</ErrorMessage>
<p>
<Link to="/login">Login</Link>
<Link to={{ pathname: "/login", state: { from: location } }}>
Login
</Link>
</p>
<p>
<Link to="/register">Register</Link>
<Link to={{ pathname: "/register", state: { from: location } }}>
Register
</Link>
</p>
</div>
</Modal>

View File

@ -176,6 +176,13 @@
dependencies:
regenerator-runtime "^0.13.4"
"@babel/runtime@^7.7.6":
version "7.16.3"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.3.tgz#b86f0db02a04187a3c17caa77de69840165d42d5"
integrity sha512-WBwekcqacdY2e9AF/Q7WLFUWmdJGJTkbjqTjoMDgXkVZ3ZRUvOPsLb5KdwISoQVsbP+DQzVZW4Zhci0DvpbNTQ==
dependencies:
regenerator-runtime "^0.13.4"
"@babel/template@^7.15.4":
version "7.15.4"
resolved "https://registry.npmjs.org/@babel/template/-/template-7.15.4.tgz"
@ -1548,6 +1555,13 @@ history@^4.9.0:
tiny-warning "^1.0.0"
value-equal "^1.0.1"
history@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/history/-/history-5.1.0.tgz#2e93c09c064194d38d52ed62afd0afc9d9b01ece"
integrity sha512-zPuQgPacm2vH2xdORvGGz1wQMuHSIB56yNAy5FnLuwOwgSYyPKptJtcMm6Ev+hRGeS+GzhbmRacHzvlESbFwDg==
dependencies:
"@babel/runtime" "^7.7.6"
hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
@ -2666,6 +2680,13 @@ react-router@5.2.1:
tiny-invariant "^1.0.2"
tiny-warning "^1.0.0"
react-router@6:
version "6.0.2"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.0.2.tgz#bd2b0fa84fd1d152671e9f654d9c0b1f5a7c86da"
integrity sha512-8/Wm3Ed8t7TuedXjAvV39+c8j0vwrI5qVsYqjFr5WkJjsJpEvNSoLRUbtqSEYzqaTUj1IV+sbPJxvO+accvU0Q==
dependencies:
history "^5.1.0"
react-textarea-autosize@^8.3.2:
version "8.3.3"
resolved "https://registry.yarnpkg.com/react-textarea-autosize/-/react-textarea-autosize-8.3.3.tgz#f70913945369da453fd554c168f6baacd1fa04d8"