alive2212 / laravel-mobile-passport
This is an illuminate package for one time authentication (OTP) with OAuth2 Base
Requires
Requires (Dev)
- dev-master
- v4.0.8
- v4.0.7
- v4.0.6
- v4.0.5
- v4.0.4
- v4.0.3
- v4.0.2
- v4.0.1
- v4.0.0
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.0.27
- v1.0.26
- v1.0.25
- v1.0.24
- v1.0.23
- v1.0.22
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-laravel6
This package is auto-updated.
Last update: 2024-11-30 01:59:19 UTC
README
This is where your description should go. Take a look at contributing.md to see a to do list.
Installation
Via Composer
$ composer require alive2212/laravel-mobile-passport
add to service provider 'config/app.php'
'providers' => [ ... /* * Authentication service */ Alive2212\LaravelMobilePassport\LaravelMobilePassportServiceProvider::class, ],
if use Lumen add following service provider at then end of 'bootstrap/app.php'
$app->register(Alive2212\LaravelMobilePassport\LaravelMobilePassportServiceProvider::class); $app->router->group([ 'namespace' => 'Alive2212\LaravelMobilePassport\Http\Controllers', ], function ($router) { require Alive2212\LaravelMobilePassport\LaravelMobilePassport::getDir() . '/lumen_routes.php'; });
migrate all database
$ php artisan migrate
add following code into AuthServiceProvider in 'boot' method
public function boot() { $this->registerPolicies(); Passport::routes(); LaravelMobilePassport::initPassportTokenCan(); LaravelMobilePassportSingleton::$otpCallBack = function ( Request $request, User $user, AliveMobilePassportDevice $device, $token ) { // dispatch send sms job here to send notification }; LaravelMobilePassportSingleton::$otpConfirmCallBack = function ( Request $request, User $user, PersonalAccessTokenResult $token, ResponseModel $response ) { // put something here like update user name with request fields }; }
- tip: if ENV_DEBUG in .env file set to false don't return any data in register by token
add 'phone_number' & 'country_code' into model $fillable variable:
protected $fillable = [ 'name', 'email', 'password', 'phone_number', 'country_code', ];
publish vendor files with following command:
php artisan vendor:publish --tag laravel-mobile-passport.lang
php artisan vendor:publish --tag laravel-mobile-passport.config
php artisan vendor:publish --tag laravel-mobile-passport.migrations
php artisan vendor:publish --tag laravel-mobile-passport.models
User model must be extended from BaseAuthModel
In the next step you should install following package and it's version related to your laravel version.
- phoenix/eloquent-meta
- fico7489/laravel-pivot
Add flowing code into app\User.php
/** * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function roles() { return $this->belongsToMany( AliveMobilePassportRole::class, 'alive_mobile_passport_role_user', 'user_id', 'role_id' ); }
Finally run following command to install passport dependency
$ art passport:install
Optional for add routes you can put following into boot method at AppServiceProvider
// add mobile passport routes LaravelMobilePassport::routes(null,['middleware'=>'cors']);
Usage
1- create roles what you want in to alive_mobile_passport_roles *tip: title of roles must unique
You can use following to get current user scopes
$request['access_token'])
Change log
Please see the changelog for more information on what has changed recently.
Testing
$ composer test
Relation of this package with another one is:
- array helper -> nothing
- laravel excel helper -> nothing
- laravel onion pattern -> nothing
- laravel query helper -> nothing
- laravel reflection helper -> nothing
- laravel request helper -> nothing
- laravel string helper -> nothing
- laravel smart response -> array helper
- laravel smart restful -> laravel excel helper, laravel onion pattern, laravel query helper, laravel reflection helper, laravel smart response, laravel string helper
- laravel passport auth -> laravel smart restful
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email author email instead of using the issue tracker.
Credits
License
license. Please see the license file for more information.