Skip to content

Commit

Permalink
Do not allow Teams page without login
Browse files Browse the repository at this point in the history
- Fixes #6631
  • Loading branch information
royallsilwallz committed Nov 14, 2024
1 parent 4cda8eb commit 9c04ab9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion frontend/src/views/teams.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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}/`);
Expand All @@ -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));
Expand Down

0 comments on commit 9c04ab9

Please sign in to comment.