@henrybuilt/react-app
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "@henrybuilt/react-app", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "react-scripts test --watchAll" | ||
}, | ||
@@ -19,3 +19,14 @@ "author": "", | ||
"redux": "^4.0.4" | ||
}, | ||
"devDependencies": { | ||
"npm": "^6.13.4", | ||
"lodash": "^4.17.15", | ||
"react-scripts": "^3.3.0", | ||
"react": "^16.10.2", | ||
"react-dom": "^16.10.2", | ||
"henrybuilt-react-library": "^1.0.22", | ||
"react-router-dom": "^5.1.2", | ||
"enzyme": "^3.11.0", | ||
"enzyme-adapter-react-16": "^1.15.2" | ||
} | ||
} |
import {React, className, Component} from 'henrybuilt-react-library'; | ||
import {Redirect} from 'react-router-dom'; | ||
import _ from 'lodash'; | ||
@@ -8,8 +9,5 @@ class Page extends Component { | ||
render(content) { | ||
var {isLoggedIn} = this.props.session; | ||
var hasPermission = this.authGroup === 'anyone' ? true : isLoggedIn; | ||
if (!this.hasPermission) window.location = `${this.accountsDomain}/login`; | ||
if (!hasPermission) window.location = `${this.accountsDomain}/login`; | ||
return hasPermission ? ( | ||
return this.hasPermission ? ( | ||
<div {...className([`page ${_.kebabCase(this.key)}-page`, this.className])}> | ||
@@ -21,2 +19,18 @@ {content} | ||
get hasPermission() { | ||
var authGroupNumberMap = { | ||
anyone: 10, | ||
user: 20, | ||
employee: 30, | ||
admin: 40 | ||
}; | ||
var authGroupNumbers = { | ||
page: authGroupNumberMap[this.authGroup] || 1000, | ||
user: authGroupNumberMap[_.get(this.props.session.user, 'authGroup', 'anyone')] || 10, //if invalid authGroup effectivly anyone | ||
} | ||
return authGroupNumbers.page <= authGroupNumbers.user; | ||
} | ||
get accountsDomain() { | ||
@@ -23,0 +37,0 @@ return process.env.NODE_ENV === 'development' ? 'http://localhost:3000' : 'https://henrybuilt.com'; |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
13032
17
320
1
9