-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract a few things. Added bearerToken method to request.
- Loading branch information
1 parent
1ac7be1
commit 8ed72ef
Showing
3 changed files
with
78 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace Illuminate\Auth; | ||
|
||
use Illuminate\Contracts\Auth\Authenticatable; | ||
|
||
/** | ||
* These methods are typically the same across all guards. | ||
*/ | ||
trait GuardHelpers | ||
{ | ||
/** | ||
* The currently authenticated user. | ||
* | ||
* @var \Illuminate\Contracts\Auth\Authenticatable | ||
*/ | ||
protected $user; | ||
|
||
/** | ||
* The user provider implementation. | ||
* | ||
* @var \Illuminate\Contracts\Auth\UserProvider | ||
*/ | ||
protected $provider; | ||
|
||
/** | ||
* Determine if the current user is authenticated. | ||
* | ||
* @return bool | ||
*/ | ||
public function check() | ||
{ | ||
return ! is_null($this->user()); | ||
} | ||
|
||
/** | ||
* Determine if the current user is a guest. | ||
* | ||
* @return bool | ||
*/ | ||
public function guest() | ||
{ | ||
return ! $this->check(); | ||
} | ||
|
||
/** | ||
* Get the ID for the currently authenticated user. | ||
* | ||
* @return int|null | ||
*/ | ||
public function id() | ||
{ | ||
if ($this->user()) { | ||
return $this->user()->getAuthIdentifier(); | ||
} | ||
} | ||
|
||
/** | ||
* Set the current user. | ||
* | ||
* @param \Illuminate\Contracts\Auth\Authenticatable $user | ||
* @return void | ||
*/ | ||
public function setUser(Authenticatable $user) | ||
{ | ||
$this->user = $user; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters