mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-12 16:57:39 -05:00
Terms of Service added
This commit is contained in:
@@ -2,15 +2,17 @@
|
||||
import React, { useEffect } from "react";
|
||||
import { useSelector, useDispatch } from 'react-redux'
|
||||
import { authenticateUser } from "../features/user/userSlice";
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useNavigate, useLocation } from 'react-router-dom';
|
||||
/**
|
||||
* Higher-order component (HOC) to wrap restricted pages
|
||||
*/
|
||||
|
||||
const Restricted = ({ children }) => {
|
||||
const { authenticated, hasAuthenticated } = useSelector((state) => state.user);
|
||||
const { authenticated, hasAuthenticated,terms } = useSelector((state) => state.user);
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const { hash, pathname, search } = location;
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(authenticateUser({}));
|
||||
@@ -18,6 +20,9 @@ const Restricted = ({ children }) => {
|
||||
|
||||
if (hasAuthenticated) {
|
||||
if (authenticated) {
|
||||
if ((pathname != "/terms") && (terms != 1.1)) {
|
||||
navigate("/terms")
|
||||
}
|
||||
return children;
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user