| Total Complexity | 5 |
| Complexity/F | 2.5 |
| Lines of Code | 27 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | import { |
||
| 2 | config, |
||
| 3 | User |
||
| 4 | } from '../../../' |
||
| 5 | |||
| 6 | /** |
||
| 7 | * Handlebars helper, to print className and escape it string |
||
| 8 | */ |
||
| 9 | export default function isAuthorized(route, role, ctx) { |
||
| 10 | var isAuthorized = true |
||
| 11 | |||
| 12 | if (config.users.enable) { |
||
| 13 | var allowedRoutes = User.utils.getUserRoutes(role) |
||
| 14 | Array.prototype.forEach.call(allowedRoutes, (allowedRoute) => { |
||
| 15 | var reg = new RegExp(allowedRoute) |
||
| 16 | if (reg.test(route)) { |
||
| 17 | isAuthorized = false |
||
| 18 | } |
||
| 19 | }) |
||
| 20 | } |
||
| 21 | |||
| 22 | if (isAuthorized) { |
||
| 23 | return ctx.fn(this) |
||
| 24 | }else { |
||
| 25 | return ctx.inverse(this) |
||
| 26 | } |
||
| 27 | } |
||
| 28 |