Skip to content

Instantly share code, notes, and snippets.

@ssi-anik
Created July 22, 2020 16:14
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 ssi-anik/056dce6dc98ce93e84fe22780dccf224 to your computer and use it in GitHub Desktop.
Save ssi-anik/056dce6dc98ce93e84fe22780dccf224 to your computer and use it in GitHub Desktop.
A: jwt-auth with otp
<?php
namespace App\Providers;
use App\Models\Member;
use Exception;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Contracts\Auth\UserProvider;
class MemberUserProvider implements UserProvider
{
public function retrieveByToken ($identifier, $token) {
throw new Exception('Method not implemented.');
}
public function updateRememberToken (Authenticatable $user, $token) {
throw new Exception('Method not implemented.');
}
public function retrieveById ($identifier) {
return Member::find($identifier);
}
public function retrieveByCredentials (array $credentials) {
$phone = $credentials['phone'];
return Member::where('phone', $phone)->first();
}
public function validateCredentials (Authenticatable $user, array $credentials) {
$otp = $credentials['otp'];
return $otp == '12345';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment