From 75e53ae8d59a79c18c96687f8d4fdd97db7c7bcb Mon Sep 17 00:00:00 2001 From: Vladimir Metnev Date: Sat, 5 Aug 2017 18:42:59 +0300 Subject: [PATCH] feat(src/common/components/addons/RouteAuth): remove handling on lazy loading from RouteAuth --- .../components/addons/RouteAuth/index.jsx | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/common/components/addons/RouteAuth/index.jsx diff --git a/src/common/components/addons/RouteAuth/index.jsx b/src/common/components/addons/RouteAuth/index.jsx new file mode 100644 index 00000000..fbf21ea4 --- /dev/null +++ b/src/common/components/addons/RouteAuth/index.jsx @@ -0,0 +1,25 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import {Route, Redirect} from 'react-router-dom' + +/** + * Component that protects route from unauthorized users. + */ +class RouteAuth extends Component { + static propTypes = { + canAccess: PropTypes.func, + path: PropTypes.string + } + + render () { + const {canAccess, path} = this.props + + console.log( + `User has access to "${path}" path: ${canAccess(path) ? 'YES' : 'NO'}` + ) + + return canAccess(path) ? : + } +} + +export default RouteAuth