mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-15 02:07:50 -05:00
actually redirects to terms
This commit is contained in:
@@ -22,9 +22,10 @@ const Restricted = ({ children }) => {
|
|||||||
if (authenticated) {
|
if (authenticated) {
|
||||||
if ((pathname != "/terms") && (terms != 1.1)) {
|
if ((pathname != "/terms") && (terms != 1.1)) {
|
||||||
navigate("/terms")
|
navigate("/terms")
|
||||||
}
|
} else {
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
navigate("/login")
|
navigate("/login")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useState } from "react";
|
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 { loginUser } from "../features/user/userSlice";
|
||||||
import { useDispatch } from 'react-redux';
|
|
||||||
import {
|
import {
|
||||||
Container,
|
Container,
|
||||||
Header,
|
Header,
|
||||||
@@ -28,20 +28,24 @@ const forgotStyle = {
|
|||||||
|
|
||||||
|
|
||||||
const Login = (props) => {
|
const Login = (props) => {
|
||||||
|
const { terms } = useSelector((state) => state.user);
|
||||||
const [loginMessage, setLoginMessage] = useState("");
|
const [loginMessage, setLoginMessage] = useState("");
|
||||||
const [email, setEmail] = useState("");
|
const [email, setEmail] = useState("");
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
let [searchParams] = useSearchParams();
|
let [searchParams] = useSearchParams();
|
||||||
const nextLocation = searchParams.get("nextLocation");
|
const nextLocation = searchParams.get("nextLocation");
|
||||||
|
const location = useLocation();
|
||||||
|
const { hash, pathname, search } = location;
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const loginSubmit = async (event) => {
|
const loginSubmit = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const result = await dispatch(loginUser({ email, password })).unwrap();
|
const result = await dispatch(loginUser({ email, password })).unwrap();
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
|
if ((pathname != "/terms") && (terms != 1.1)) {
|
||||||
if (nextLocation) {
|
navigate("/terms")
|
||||||
|
} else if (nextLocation) {
|
||||||
switch (nextLocation) {
|
switch (nextLocation) {
|
||||||
case "frontend":
|
case "frontend":
|
||||||
window.location = process.env.REACT_APP_FRONTEND_SERVER;
|
window.location = process.env.REACT_APP_FRONTEND_SERVER;
|
||||||
|
|||||||
Reference in New Issue
Block a user