add redirect feature for authentication
This commit is contained in:
@ -21,7 +21,7 @@ export function fetchLoginRedirect() {
|
||||
const loginSearch = localStorage.getItem(LOGIN_SEARCH);
|
||||
clearLoginRedirect();
|
||||
return {
|
||||
pathname: loginPathname || "/",
|
||||
pathname: loginPathname || "/wifi-configuration",
|
||||
search: (loginPathname && loginSearch) || undefined
|
||||
};
|
||||
}
|
||||
|
24
interface/src/authentication/UnauthenticatedRoute.js
Normal file
24
interface/src/authentication/UnauthenticatedRoute.js
Normal file
@ -0,0 +1,24 @@
|
||||
import * as React from 'react';
|
||||
import {
|
||||
Redirect, Route
|
||||
} from "react-router-dom";
|
||||
|
||||
import { withAuthenticationContext } from './Context.js';
|
||||
import * as Authentication from './Authentication';
|
||||
|
||||
class UnauthenticatedRoute extends React.Component {
|
||||
render() {
|
||||
const { component:Component, ...rest } = this.props;
|
||||
const renderComponent = (props) => {
|
||||
if (this.props.authenticationContext.jwt) {
|
||||
return (<Redirect to={Authentication.fetchLoginRedirect()} />);
|
||||
}
|
||||
return (<Component {...props} />);
|
||||
}
|
||||
return (
|
||||
<Route {...rest} render={renderComponent} />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withAuthenticationContext(UnauthenticatedRoute);
|
Reference in New Issue
Block a user