refactor: MONOREPO
This commit is contained in:
18
frontend/src/security/AuthRoute.tsx
Normal file
18
frontend/src/security/AuthRoute.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { Route, Redirect } from "react-router-dom";
|
||||
|
||||
interface IAuthRouteProps {
|
||||
path: string;
|
||||
component: any;
|
||||
isAuth: () => boolean;
|
||||
}
|
||||
|
||||
export default class AuthRoute extends React.Component<IAuthRouteProps, {}> {
|
||||
render() {
|
||||
const auth = this.props.isAuth();
|
||||
return <Route path={this.props.path} component={
|
||||
() => auth ? <this.props.component /> : <Redirect to="/login" />
|
||||
} />;
|
||||
}
|
||||
};
|
||||
7
frontend/src/security/Token.ts
Normal file
7
frontend/src/security/Token.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export function setSessionToken(window: Window, token: string) {
|
||||
window.sessionStorage.setItem("sessionToken", token);
|
||||
};
|
||||
|
||||
export function removeSessionToken(window: Window) {
|
||||
window.sessionStorage.removeItem("sessionToken");
|
||||
}
|
||||
Reference in New Issue
Block a user