-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(adds functionality to enforce user authentication):
- add functionality to prevent un-authenticated users from accessing functionalities that require user login [ Delivers #163355244]
- Loading branch information
vincent Onyango
committed
Jan 30, 2019
1 parent
bcece85
commit 00a8b7f
Showing
8 changed files
with
110 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
Route, | ||
Redirect, | ||
} from 'react-router-dom'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
// import { ReactComponent } from '*.svg'; | ||
import Cookies from 'js-cookie'; | ||
|
||
const IsAuthenticated = ({ component: Component, ...props }) => ( | ||
<Route | ||
{...props} | ||
render={properties => ( | ||
Cookies.get('username') ? <Component {...properties} /> | ||
: ( | ||
<Redirect to={{ | ||
pathname: '/login', | ||
state: { from: props.location }, | ||
}} | ||
/> | ||
) | ||
)} | ||
/> | ||
); | ||
|
||
|
||
IsAuthenticated.propTypes = { | ||
component: PropTypes.func.isRequired, | ||
location: PropTypes.shape().isRequired, | ||
}; | ||
|
||
export default IsAuthenticated; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters