feat: check whether user has necessary scope

This commit is contained in:
2025-03-25 19:09:33 +01:00
parent 81d6a02229
commit 03ed843679
3 changed files with 21 additions and 3 deletions

View File

@@ -2,9 +2,15 @@ import { FormEvent, useEffect, useState } from "react";
import { apiAuth, loadPlayers, User } from "./api";
import { useSession } from "./Session";
import { ErrorState } from "./types";
import { useNavigate } from "react-router";
const TeamPanel = () => {
const { teams } = useSession();
const { user, teams } = useSession();
const navigate = useNavigate();
useEffect(() => {
user?.scopes.includes(`team:${teams?.activeTeam}`) ||
navigate("/", { replace: true });
}, [user]);
const newPlayerTemplate = {
id: 0,
username: "",