Gate class abstract final

Authorization (Gate::allows, Gate::authorize).

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

gate → AuthorizationGate
The gate of the current container.
no setter

Static Methods

after(GateAfterHook hook) → void
Runs hook after every check.
allows(String ability, [List<Object?> args = const []]) → Future<bool>
Whether the authenticated user may do ability with args.
any(Iterable<String> abilities, [List<Object?> args = const []]) → Future<bool>
Whether any of the abilities is allowed.
authorize(String ability, [List<Object?> args = const []]) → Future<AuthResponse>
Allows ability or throws a 403 with the policy's message.
before(GateBeforeHook hook) → void
Runs hook before every check; a non-null result decides it.
check(Iterable<String> abilities, [List<Object?> args = const []]) → Future<bool>
Whether every one of the abilities is allowed.
define(String ability, GateCallback callback) → void
Defines ability: Gate.define('edit-post', (user, [post]) => ...).
denies(String ability, [List<Object?> args = const []]) → Future<bool>
Whether the authenticated user may not do ability.
forUser(Authenticatable? user) → AuthorizationGate
The gate checking as user instead of the authenticated one.
has(String ability) → bool
Whether ability is defined.
inspect(String ability, [List<Object?> args = const []]) → Future<AuthResponse>
The full answer for ability: allowed or denied, with a message and code.
none(Iterable<String> abilities, [List<Object?> args = const []]) → Future<bool>
Whether none of the abilities is allowed.
policy<T extends Object>(Policy<T> policy) → void
Registers policy for its model type.