mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-22 22:53:55 -07:00
16 lines
485 B
TypeScript
16 lines
485 B
TypeScript
import React from 'react';
|
|
import { Navigate } from 'react-router-dom';
|
|
|
|
import { ServerSelectors } from '@app/store';
|
|
import { App } from '@app/types';
|
|
import { useAppSelector } from '@app/store';
|
|
import { AuthenticationService } from '@app/api';
|
|
|
|
const AuthGuard = () => {
|
|
const state = useAppSelector(s => ServerSelectors.getState(s));
|
|
return !AuthenticationService.isConnected(state)
|
|
? <Navigate to={App.RouteEnum.LOGIN} />
|
|
: <div></div>;
|
|
};
|
|
|
|
export default AuthGuard;
|