AuthorizationGate class final

Ability registry and checker (Laravel Gate). One instance per application; forUser yields a view bound to a specific user.

Constructors

AuthorizationGate({Future<Authenticatable?> userResolver()?})

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

after(GateAfterHook hook) → void
allows(String ability, [List<Object?> args = const []]) → Future<bool>
any(Iterable<String> abilities, [List<Object?> args = const []]) → Future<bool>
At least one ability allowed.
authorize(String ability, [List<Object?> args = const []]) → Future<AuthResponse>
Throws AuthorizationException (403) when denied.
before(GateBeforeHook hook) → void
check(Iterable<String> abilities, [List<Object?> args = const []]) → Future<bool>
Every ability allowed.
define(String ability, GateCallback callback) → void
Registers an ability.
denies(String ability, [List<Object?> args = const []]) → Future<bool>
forUser(Authenticatable? user) → AuthorizationGate
A gate that checks abilities for user instead of the current user.
has(String ability) → bool
inspect(String ability, [List<Object?> args = const []]) → Future<AuthResponse>
Full result with message/code.
none(Iterable<String> abilities, [List<Object?> args = const []]) → Future<bool>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
policy<T extends Object>(Policy<T> policy) → void
Registers policy for instances (and the Type) of T. The first policy whose type matches an instance (is check) wins, so register subclasses before their parents.
policyFor(Object? target) → Policy<Object>?
Finds the policy registered for target (an instance or a Type).
toString() → String
A string representation of this object.
inherited

Operators

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