feat: check whether user has necessary scope
This commit is contained in:
parent
81d6a02229
commit
03ed843679
@ -3,6 +3,7 @@ import { apiAuth } from "./api";
|
|||||||
import { PlayerRanking } from "./types";
|
import { PlayerRanking } from "./types";
|
||||||
import RaceChart from "./RaceChart";
|
import RaceChart from "./RaceChart";
|
||||||
import { useSession } from "./Session";
|
import { useSession } from "./Session";
|
||||||
|
import { useNavigate } from "react-router";
|
||||||
|
|
||||||
const MVPChart = () => {
|
const MVPChart = () => {
|
||||||
let initialData = {} as PlayerRanking[];
|
let initialData = {} as PlayerRanking[];
|
||||||
@ -10,7 +11,12 @@ const MVPChart = () => {
|
|||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
const [showStd, setShowStd] = useState(false);
|
const [showStd, setShowStd] = useState(false);
|
||||||
const { teams } = useSession();
|
const { user, teams } = useSession();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
useEffect(() => {
|
||||||
|
user?.scopes.includes(`team:${teams?.activeTeam}`) ||
|
||||||
|
navigate("/", { replace: true });
|
||||||
|
}, [user]);
|
||||||
|
|
||||||
async function loadData() {
|
async function loadData() {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
@ -11,6 +11,7 @@ import {
|
|||||||
} from "reagraph";
|
} from "reagraph";
|
||||||
import { customTheme } from "./NetworkTheme";
|
import { customTheme } from "./NetworkTheme";
|
||||||
import { useSession } from "./Session";
|
import { useSession } from "./Session";
|
||||||
|
import { useNavigate } from "react-router";
|
||||||
|
|
||||||
interface NetworkData {
|
interface NetworkData {
|
||||||
nodes: GraphNode[];
|
nodes: GraphNode[];
|
||||||
@ -45,7 +46,12 @@ export const GraphComponent = () => {
|
|||||||
const [likes, setLikes] = useState(2);
|
const [likes, setLikes] = useState(2);
|
||||||
const [popularity, setPopularity] = useState(false);
|
const [popularity, setPopularity] = useState(false);
|
||||||
const [mutuality, setMutuality] = useState(false);
|
const [mutuality, setMutuality] = useState(false);
|
||||||
const { teams } = useSession();
|
const { user, teams } = useSession();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
useEffect(() => {
|
||||||
|
user?.scopes.includes(`team:${teams?.activeTeam}`) ||
|
||||||
|
navigate("/", { replace: true });
|
||||||
|
}, [user]);
|
||||||
|
|
||||||
async function loadData() {
|
async function loadData() {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
@ -2,9 +2,15 @@ import { FormEvent, useEffect, useState } from "react";
|
|||||||
import { apiAuth, loadPlayers, User } from "./api";
|
import { apiAuth, loadPlayers, User } from "./api";
|
||||||
import { useSession } from "./Session";
|
import { useSession } from "./Session";
|
||||||
import { ErrorState } from "./types";
|
import { ErrorState } from "./types";
|
||||||
|
import { useNavigate } from "react-router";
|
||||||
|
|
||||||
const TeamPanel = () => {
|
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 = {
|
const newPlayerTemplate = {
|
||||||
id: 0,
|
id: 0,
|
||||||
username: "",
|
username: "",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user