mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-20 12:46:01 -05:00
actually redirects to terms
This commit is contained in:
@@ -22,9 +22,10 @@ const Restricted = ({ children }) => {
|
||||
if (authenticated) {
|
||||
if ((pathname != "/terms") && (terms != 1.1)) {
|
||||
navigate("/terms")
|
||||
}
|
||||
} else {
|
||||
return children;
|
||||
}
|
||||
}
|
||||
else {
|
||||
navigate("/login")
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user