Created
July 5, 2017 10:59
-
-
Save radicalloop/163fb808618c0054baa47435ea18974c to your computer and use it in GitHub Desktop.
Reimplemet IlluminateAuthAdapter of jwt-auth for kbwebs/multiauth
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
<?php | |
namespace App\Providers\Auth; | |
use Kbwebs\MultiAuth\MultiManager; | |
use Tymon\JWTAuth\Providers\Auth\AuthInterface; | |
class IlluminateAuthAdapter implements AuthInterface | |
{ | |
/** | |
* @var \Illuminate\Auth\AuthManager | |
*/ | |
protected $auth; | |
/** | |
* @param \Illuminate\Auth\AuthManager $auth | |
*/ | |
public function __construct(MultiManager $auth) | |
{ | |
$this->auth = $auth; | |
} | |
/** | |
* Check a user's credentials. | |
* | |
* @param array $credentials | |
* @return bool | |
*/ | |
public function byCredentials(array $credentials = []) | |
{ | |
return $this->auth->user()->once($credentials); | |
} | |
/** | |
* Authenticate a user via the id. | |
* | |
* @param mixed $id | |
* @return bool | |
*/ | |
public function byId($id) | |
{ | |
return $this->auth->user()->onceUsingId($id); | |
} | |
/** | |
* Get the currently authenticated user. | |
* | |
* @return mixed | |
*/ | |
public function user() | |
{ | |
return $this->auth->user()->user(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment