Created
July 22, 2020 16:14
-
-
Save ssi-anik/056dce6dc98ce93e84fe22780dccf224 to your computer and use it in GitHub Desktop.
A: jwt-auth with otp
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; | |
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