mirror of
https://github.com/pawelmalak/flame.git
synced 2026-03-11 06:53:12 +08:00
Moved auth form. Added auto login and logout functionality
This commit is contained in:
13
client/src/components/Routing/ProtectedRoute.tsx
Normal file
13
client/src/components/Routing/ProtectedRoute.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { useSelector } from 'react-redux';
|
||||
import { Redirect, Route, RouteProps } from 'react-router';
|
||||
import { State } from '../../store/reducers';
|
||||
|
||||
export const ProtectedRoute = ({ ...rest }: RouteProps) => {
|
||||
const { isAuthenticated } = useSelector((state: State) => state.auth);
|
||||
|
||||
if (isAuthenticated) {
|
||||
return <Route {...rest} />;
|
||||
} else {
|
||||
return <Redirect to="/settings/app" />;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user