adonis-guard
Advanced tools
Comparing version 1.0.0-beta.4 to 1.0.0-beta.5
@@ -0,1 +1,11 @@ | ||
<a name="1.0.0-beta.5"></a> | ||
# [1.0.0-beta.5](https://github.com/RomainLanz/adonis-guard/compare/1.0.0-beta.4...1.0.0-beta.5) (2018-09-11) | ||
### Bug Fixes | ||
* **tag:** allow to have only one arg ([d44b585](https://github.com/RomainLanz/adonis-guard/commit/d44b585)) | ||
<a name="1.0.0-beta.4"></a> | ||
@@ -2,0 +12,0 @@ # [1.0.0-beta.4](https://github.com/RomainLanz/adonis-guard/compare/1.0.0-beta.3...1.0.0-beta.4) (2018-07-20) |
{ | ||
"name": "adonis-guard", | ||
"version": "1.0.0-beta.4", | ||
"version": "1.0.0-beta.5", | ||
"main": "index.js", | ||
@@ -13,3 +13,3 @@ "repository": "git@github.com:RomainLanz/adonis-guard.git", | ||
"@adonisjs/generic-exceptions": "^2.0.1", | ||
"@slynova/fence": "^1.0.4", | ||
"@slynova/fence": "^1.0.6", | ||
"lodash": "^4.17.10", | ||
@@ -19,3 +19,3 @@ "pluralize": "^7.0.0" | ||
"devDependencies": { | ||
"@adonisjs/ace": "^5.0.3", | ||
"@adonisjs/ace": "^5.0.5", | ||
"@adonisjs/fold": "^4.0.9", | ||
@@ -25,3 +25,3 @@ "@slynova/eslint-config": "^1.0.5", | ||
"edge.js": "^1.1.4", | ||
"eslint": "^5.1.0", | ||
"eslint": "^5.5.0", | ||
"japa": "^1.0.6" | ||
@@ -28,0 +28,0 @@ }, |
@@ -39,9 +39,6 @@ # Adonis Guard 🔰 | ||
const Gate = use('Gate') | ||
const MyPolicy = use('App/Policies/MyPolicy') | ||
Gate.policy(myResource, MyPolicy) | ||
Gate.policy('App/Models/MyResource', 'App/Policies/MyPolicy') | ||
``` | ||
> `myResource` could be a JSON object (with `_className` key), an instance, a class, or a simple string. | ||
## Usage | ||
@@ -48,0 +45,0 @@ |
@@ -43,3 +43,4 @@ 'use strict' | ||
compile (compiler, lexer, buffer, { body, childs, lineno }) { | ||
const [ability, resource, user] = this._compileStatement(lexer, body, lineno).toStatement() | ||
const args = this._compileStatement(lexer, body, lineno).toStatement() | ||
const [ability, resource, user] = Array.isArray(args) ? args : [args] | ||
@@ -46,0 +47,0 @@ buffer.writeLine(`if (this.context.resolve('guard').allows(${ability}, ${resource}, ${user})) {`) |
@@ -43,3 +43,4 @@ 'use strict' | ||
compile (compiler, lexer, buffer, { body, childs, lineno }) { | ||
const [ability, resource, user] = this._compileStatement(lexer, body, lineno).toStatement() | ||
const args = this._compileStatement(lexer, body, lineno).toStatement() | ||
const [ability, resource, user] = Array.isArray(args) ? args : [args] | ||
@@ -46,0 +47,0 @@ buffer.writeLine(`if (this.context.resolve('guard').denies(${ability}, ${resource}, ${user})) {`) |
17248
323
119
Updated@slynova/fence@^1.0.6