/** * @param $route * @param $request * @param null $scope * @return null|BridgeResponse */ public function filter($route, $request, $scope = null) { $beforeAccessResult = $this->dispatcher->until('oauth.access.before', array($scope)); if ($beforeAccessResult) { return null; } /** @var BridgeRequest $bridgeRequest */ $bridgeRequest = BridgeRequest::createFromRequest($request); $bridgeResponse = new BridgeResponse(); $resController = $this->server->getResourceController(); if (!$resController->verifyResourceRequest($bridgeRequest, $bridgeResponse, $scope)) { $this->dispatcher->fire('oauth.access.failed'); return $bridgeResponse; } $token = $resController->getAccessTokenData($bridgeRequest, $bridgeResponse); $client = $this->clientRepo->find($token['client_id']); $tokenScope = $token['scope']; $user = null; if (isset($token['user_id'])) { $user = $this->userProvider->retrieveById($token['user_id']); } if ($tokenScope) { $tokenScope = explode(' ', $tokenScope); } $eventPayload = array($client, $user, $tokenScope); $this->dispatcher->fire('oauth.access.valid', $eventPayload); }
/** * Get the user for the given credentials. * * @param array $credentials * @return \Illuminate\Auth\Reminders\RemindableInterface */ public function getUser(array $credentials) { $user = $this->users->retrieveByCredentials($credentials); if ($user and !$user instanceof RemindableInterface) { throw new \UnexpectedValueException("User must implement Remindable interface."); } return $user; }
/** * Get the user for the given credentials. * * @param array $credentials * @return \Illuminate\Contracts\Auth\CanResetPassword * * @throws \UnexpectedValueException */ public function getUser(array $credentials) { $credentials = array_except($credentials, ['token']); $user = $this->users->retrieveByCredentials($credentials); if ($user && !$user instanceof CanResetPasswordContract) { throw new UnexpectedValueException("User must implement CanResetPassword interface."); } return $user; }
/** * Get the user for the given credentials. * * @param array $credentials * * @throws \UnexpectedValueException * * @return \Illuminate\Auth\Reminders\RemindableInterface */ public function getUser(array $credentials) { $credentials = array_except($credentials, ['token']); $user = $this->users->retrieveByCredentials($credentials); $user = is_null($user) ? null : new User($user); if ($user && !$user instanceof RemindableInterface) { throw new \UnexpectedValueException('User must implement Remindable interface.'); } return $user; }
/** * Attempt to authenticate a user using the given credentials. * * @param array $credentials * @param bool $remember * @param bool $login * @return bool */ public function attempt(array $credentials = array(), $remember = false, $login = true) { $this->fireAttemptEvent($credentials, $remember, $login); $user = $this->provider->retrieveByCredentials($credentials); // If an implementation of UserInterface was returned, we'll ask the provider // to validate the user against the given credentials, and if they are in // fact valid we'll log the users into the application and return true. if ($user instanceof UserInterface) { if ($this->provider->validateCredentials($user, $credentials)) { if ($login) { $this->login($user, $remember); } return true; } } return false; }
/** * Refresh the remember token for the user. * * @param \Illuminate\Auth\UserInterface $user * @return void */ protected function refreshRememberToken(UserInterface $user) { $user->setRememberToken($token = str_random(60)); $this->provider->updateRememberToken($user, $token); }
/** * Log the given user ID into the application without sessions or cookies. * * @param mixed $id * @return bool */ public function onceUsingId($id) { $this->setUser($this->provider->retrieveById($id)); return $this->user instanceof UserInterface; }
/** * Retrive user from auth token. * * @param AuthToken $token * @return UserInterface|null */ public function user(AuthToken $token) { return $this->users->retrieveByID($token->getAuthIdentifier()); }
/** * Log the given user ID into the application. * * @param mixed $id * @param bool $remember * @return \Illuminate\Auth\UserInterface */ public function loginUsingId($id, $remember = false) { $this->session->put($this->getName(), $id); return $this->login($this->provider->retrieveById($id), $remember); }