Skip to content

Instantly share code, notes, and snippets.

@radicalloop
Created July 5, 2017 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radicalloop/163fb808618c0054baa47435ea18974c to your computer and use it in GitHub Desktop.
Save radicalloop/163fb808618c0054baa47435ea18974c to your computer and use it in GitHub Desktop.
Reimplemet IlluminateAuthAdapter of jwt-auth for kbwebs/multiauth
<?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