You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
944 B
40 lines
944 B
<?php
|
|
|
|
namespace App\Auth;
|
|
|
|
use Laravel\Passport\Bridge\UserRepository;
|
|
use Laravel\Passport\Bridge\UserRepositoryInterface;
|
|
use Laravel\Passport\Bridge\User;
|
|
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
|
use App\Models\User as UserModel;
|
|
|
|
class PassportUserRepository extends UserRepository
|
|
{
|
|
/**
|
|
* OAuth2.
|
|
*
|
|
* @param string $username
|
|
* @param string $password
|
|
* @param string $grantType
|
|
* @param ClientEntityInterface $clientEntity
|
|
* @return User|null
|
|
*/
|
|
public function getUserEntityByUserCredentials(
|
|
$username,
|
|
$password,
|
|
$grantType,
|
|
ClientEntityInterface $clientEntity
|
|
) {
|
|
$user = UserModel::where('email', $username)->first();
|
|
|
|
if (! $user) {
|
|
return null;
|
|
}
|
|
|
|
if (md5($password) === $user->password) {
|
|
return new User($user->getAuthIdentifier());
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|