Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
feat(src/common/components/addons/RouteAuth): remove handling on lazy…
Browse files Browse the repository at this point in the history
… loading from RouteAuth
  • Loading branch information
Metnew committed Aug 5, 2017
1 parent 9503508 commit 75e53ae
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/common/components/addons/RouteAuth/index.jsx
Original file line number Diff line number Diff line change
@@ -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) ? <Route {...this.props} /> : <Redirect to="/auth" />
}
}

export default RouteAuth

0 comments on commit 75e53ae

Please sign in to comment.