From 9c04ab96fe2bc66e4f6579111e03cb0c90e98ae8 Mon Sep 17 00:00:00 2001 From: royallsilwallz Date: Thu, 14 Nov 2024 17:17:09 +0545 Subject: [PATCH] Do not allow Teams page without login - Fixes #6631 --- frontend/src/views/teams.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/teams.js b/frontend/src/views/teams.js index 8f2383e7e6..d3f73c6364 100644 --- a/frontend/src/views/teams.js +++ b/frontend/src/views/teams.js @@ -1,6 +1,6 @@ import { useState, useEffect } from 'react'; import { useSelector } from 'react-redux'; -import { Link, useNavigate, useParams } from 'react-router-dom'; +import { Link, useNavigate, useParams, useLocation } from 'react-router-dom'; import { FormattedMessage } from 'react-intl'; import { Form } from 'react-final-form'; import { @@ -421,6 +421,8 @@ export function EditTeam(props) { export function TeamDetail() { const { id } = useParams(); useSetTitleTag(`Team #${id}`); + const location = useLocation(); + const navigate = useNavigate(); const userDetails = useSelector((state) => state.auth.userDetails); const token = useSelector((state) => state.auth.token); const [error, loading, team] = useFetch(`teams/${id}/`); @@ -433,6 +435,16 @@ export function TeamDetail() { const [managers, setManagers] = useState([]); const [members, setMembers] = useState([]); + useEffect(() => { + if (!token) { + navigate('/login', { + state: { + from: location.pathname, + }, + }); + } + }, [location.pathname, navigate, token]); + useEffect(() => { if (team && team.members) { setManagers(filterActiveManagers(team.members));