guard method
Sets the authentication guard to the specified guard name.
This method changes the current user guard to the specified guard, which determines the user provider and authentication logic to use. If the specified guard is not defined in the configuration, an InvalidArgumentException is thrown.
Returns the current instance of the Auth
class.
Throws:
- InvalidArgumentException if the specified guard is not defined.
Implementation
Auth guard(String guard) {
if (Config().get('auth')['guards'][guard] == null) {
throw InvalidArgumentException('Auth guard [$guard] is not defined.');
}
_userGuard = guard;
return this;
}