actually redirects to terms

This commit is contained in:
Luke Berndt
2024-07-09 07:27:51 -04:00
parent 1cb336f258
commit bb72f1e538
2 changed files with 122 additions and 117 deletions

View File

@@ -22,9 +22,10 @@ const Restricted = ({ children }) => {
if (authenticated) {
if ((pathname != "/terms") && (terms != 1.1)) {
navigate("/terms")
}
} else {
return children;
}
}
else {
navigate("/login")
}

View File

@@ -1,7 +1,7 @@
import { useState } from "react";
import { useNavigate, useSearchParams, Link } from 'react-router-dom';
import { useNavigate, useSearchParams, Link, useLocation } from 'react-router-dom';
import { useSelector, useDispatch } from 'react-redux'
import { loginUser } from "../features/user/userSlice";
import { useDispatch } from 'react-redux';
import {
Container,
Header,
@@ -28,20 +28,24 @@ const forgotStyle = {
const Login = (props) => {
const { terms } = useSelector((state) => state.user);
const [loginMessage, setLoginMessage] = useState("");
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const navigate = useNavigate();
let [searchParams] = useSearchParams();
const nextLocation = searchParams.get("nextLocation");
const location = useLocation();
const { hash, pathname, search } = location;
const dispatch = useDispatch();
const loginSubmit = async (event) => {
event.preventDefault();
const result = await dispatch(loginUser({ email, password })).unwrap();
if (result.success) {
if (nextLocation) {
if ((pathname != "/terms") && (terms != 1.1)) {
navigate("/terms")
} else if (nextLocation) {
switch (nextLocation) {
case "frontend":
window.location = process.env.REACT_APP_FRONTEND_SERVER;