/** * Attempts to log a user into the API via the configured 'api.auth_type' * config variable in config/api.php. * * NOTE: Since this is intended for API use, it is a STATELESS implementation * and does not support remember me functionality. * * This basically replaces the login() method due to the way the AuthTrait * works. * * @return bool */ public function viaRemember() { $user = false; switch (config_item('api.auth_type')) { case 'basic': $user = $this->tryBasicAuthentication(); break; case 'digest': $user = $this->tryDigestAuthentication(); break; } if (!$user) { $this->user = null; return $user; } $this->loginUser($user); Events::trigger('didLogin', [$user]); return true; }
/** * Attempts to log a user into the API via the configured 'api.auth_type' * config variable in config/api.php. * * NOTE: Since this is intended for API use, it is a STATELESS implementation * and does not support remember me functionality. * * This basically replaces the login() method due to the way the AuthTrait * works. * * @return bool */ public function viaRemember() { $user = false; switch (config_item('api.auth_type')) { case 'basic': $user = $this->tryBasicAuthentication(); break; case 'digest': $user = $this->tryDigestAuthentication(); break; } // If the user is throttled due to too many invalid logins // or the system is under attack, kick them back. // We need to test for this after validation because we // don't want it to affect a valid login. // If throttling time is above zero, we can't allow // logins now. if ($time = (int) $this->isThrottled($user) > 0) { $this->error = sprintf(lang('api.throttled'), $time); return false; } if (!$user) { $this->user = null; return $user; } $this->loginUser($user); Events::trigger('didLogin', [$user]); return true; }