X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/e15fcf5b50e1831a90a04ded09f24e0c7b31d02e..refs/pull/3391/head:/app/Auth/Access/Guards/ExternalBaseSessionGuard.php diff --git a/app/Auth/Access/Guards/ExternalBaseSessionGuard.php b/app/Auth/Access/Guards/ExternalBaseSessionGuard.php index f3d05366d..99bfd2e79 100644 --- a/app/Auth/Access/Guards/ExternalBaseSessionGuard.php +++ b/app/Auth/Access/Guards/ExternalBaseSessionGuard.php @@ -15,8 +15,6 @@ use Illuminate\Contracts\Session\Session; * guard with 'remember' functionality removed. Basic auth and event emission * has also been removed to keep this simple. Designed to be extended by external * Auth Guards. - * - * @package Illuminate\Auth */ class ExternalBaseSessionGuard implements StatefulGuard { @@ -86,7 +84,7 @@ class ExternalBaseSessionGuard implements StatefulGuard // If we've already retrieved the user for the current request we can just // return it back immediately. We do not want to fetch the user data on // every call to this method because that would be tremendously slow. - if (! is_null($this->user)) { + if (!is_null($this->user)) { return $this->user; } @@ -94,7 +92,7 @@ class ExternalBaseSessionGuard implements StatefulGuard // First we will try to load the user using the // identifier in the session if one exists. - if (! is_null($id)) { + if (!is_null($id)) { $this->user = $this->provider->retrieveById($id); } @@ -120,7 +118,8 @@ class ExternalBaseSessionGuard implements StatefulGuard /** * Log a user into the application without sessions or cookies. * - * @param array $credentials + * @param array $credentials + * * @return bool */ public function once(array $credentials = []) @@ -137,12 +136,13 @@ class ExternalBaseSessionGuard implements StatefulGuard /** * Log the given user ID into the application without sessions or cookies. * - * @param mixed $id + * @param mixed $id + * * @return \Illuminate\Contracts\Auth\Authenticatable|false */ public function onceUsingId($id) { - if (! is_null($user = $this->provider->retrieveById($id))) { + if (!is_null($user = $this->provider->retrieveById($id))) { $this->setUser($user); return $user; @@ -154,7 +154,8 @@ class ExternalBaseSessionGuard implements StatefulGuard /** * Validate a user's credentials. * - * @param array $credentials + * @param array $credentials + * * @return bool */ public function validate(array $credentials = []) @@ -162,12 +163,12 @@ class ExternalBaseSessionGuard implements StatefulGuard return false; } - /** * Attempt to authenticate a user using the given credentials. * - * @param array $credentials - * @param bool $remember + * @param array $credentials + * @param bool $remember + * * @return bool */ public function attempt(array $credentials = [], $remember = false) @@ -178,26 +179,24 @@ class ExternalBaseSessionGuard implements StatefulGuard /** * Log the given user ID into the application. * - * @param mixed $id - * @param bool $remember + * @param mixed $id + * @param bool $remember + * * @return \Illuminate\Contracts\Auth\Authenticatable|false */ public function loginUsingId($id, $remember = false) { - if (! is_null($user = $this->provider->retrieveById($id))) { - $this->login($user, $remember); - - return $user; - } - + // Always return false as to disable this method, + // Logins should route through LoginService. return false; } /** * Log a user into the application. * - * @param \Illuminate\Contracts\Auth\Authenticatable $user - * @param bool $remember + * @param \Illuminate\Contracts\Auth\Authenticatable $user + * @param bool $remember + * * @return void */ public function login(AuthenticatableContract $user, $remember = false) @@ -210,7 +209,8 @@ class ExternalBaseSessionGuard implements StatefulGuard /** * Update the session with the given ID. * - * @param string $id + * @param string $id + * * @return void */ protected function updateSession($id) @@ -264,7 +264,7 @@ class ExternalBaseSessionGuard implements StatefulGuard */ public function getName() { - return 'login_'.$this->name.'_'.sha1(static::class); + return 'login_' . $this->name . '_' . sha1(static::class); } /** @@ -290,7 +290,8 @@ class ExternalBaseSessionGuard implements StatefulGuard /** * Set the current user. * - * @param \Illuminate\Contracts\Auth\Authenticatable $user + * @param \Illuminate\Contracts\Auth\Authenticatable $user + * * @return $this */ public function setUser(AuthenticatableContract $user) @@ -301,5 +302,4 @@ class ExternalBaseSessionGuard implements StatefulGuard return $this; } - }