Download the PHP package xutl/laravel-passport-sms without Composer
On this page you can find all versions of the php package xutl/laravel-passport-sms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package laravel-passport-sms
SMS Grant for Laravel Passport
This package is useful to combine your Oauth2 Server with SMS Login.
Installation
This package can be installed through Composer.
In Laravel 5.5 the service provider will automatically get registered. In older versions of the framework just add the service provider in config/app.php file:
How to use
- Make a POST request to https://your-site.com/oauth/token, just like you would a Password or Refresh grant.
- The POST body should contain grant_type = sms.
- The request will get routed to your User::byPassportSmsRequest() function, where you will determine if access should be granted or not.
- An access_token and refresh_token will be returned if successful.
Request
php /**
- Verify and retrieve user by custom token request.
- @param \Illuminate\Http\Request $request
- @return \Illuminate\Database\Eloquent\Model|null
- @throws \League\OAuth2\Server\Exception\OAuthServerException
*/
public function byPassportSmsequest(Request $request)
{
try {
Validator::make($request->all(), [
'phone' => [
'required',
'min:11',
'max:11',
'regex:/^1[34578]{1}[\d]{9}$|^166[\d]{8}$|^19[89]{1}[\d]{8}$/',
],
'verifyCode' => [
'required',
'max:6',
function ($attribute, $value, $fail) use ($request) {
if (!SmsVerifyCodeService::make($request->phone)->validate($value, false)) {
return $fail($attribute . ' is invalid.');
}
},
]
])->validate();
return static::phone($request->phone)->first();
} catch (\Exception $e) {
throw OAuthServerException::accessDenied($e->getMessage());
}
}
json
{
"error": "invalid_credentials",
"message": "The user credentials were incorrect."
}
Credits:
All versions of laravel-passport-sms with dependencies
PHP Build Version
Package Version
Requires
xutl/laravel-sms Version
^1.0
The package xutl/laravel-passport-sms contains the following files
Loading the files please wait ....