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()?})
A gate checking the user the resolver returns (the request's by default).

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
Runs hook after every check.
allows(String ability, [List<Object?> args = const []]) → Future<bool>
Whether the user may do ability with args.
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
Runs hook before every check; a non-null result decides it (Gate::before).
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>
Whether the user may not do ability.
forUser(Authenticatable? user) → AuthorizationGate
A gate that checks abilities for user instead of the current user.
has(String ability) → bool
Whether ability is defined.
inspect(String ability, [List<Object?> args = const []]) → Future<AuthResponse>
Full result with message/code.
none(Iterable<String> abilities, [List<Object?> args = const []]) → Future<bool>
Whether none of the abilities is allowed.
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