mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
24 lines
591 B
TypeScript
24 lines
591 B
TypeScript
import React from 'react';
|
|
import { connect } from 'react-redux';
|
|
import { Redirect } from 'react-router-dom';
|
|
|
|
import { ServerSelectors } from 'store';
|
|
import { RouteEnum } from 'types';
|
|
|
|
import { AuthenticationService } from 'api';
|
|
|
|
const AuthGuard = ({ state }: AuthGuardProps) => {
|
|
return !AuthenticationService.isConnected(state)
|
|
? <Redirect from="*" to={RouteEnum.LOGIN} />
|
|
: <div></div>;
|
|
};
|
|
|
|
interface AuthGuardProps {
|
|
state: number;
|
|
}
|
|
|
|
const mapStateToProps = state => ({
|
|
state: ServerSelectors.getState(state),
|
|
});
|
|
|
|
export default connect(mapStateToProps)(AuthGuard);
|