Skip to content

Commit 59c36ae

Browse files
author
Steve Porter
committed
feat: add User class for easy passport and mongo implementation
1 parent 09ffeff commit 59c36ae

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

README.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@ Installation using composer:
1818
composer require steveporter92/laravel-mongodb-passport
1919
```
2020

21+
You need to have your `App\User` class extend `StevePorter92\Mongodb\Auth\User.php` instead of the default `Illuminate\Foundation\Auth\User`. This user class extends larvel-mongodb eloquent user as well as adding all the standard and required authentication and laravel passport traits.
22+
23+
```
24+
<?php
25+
26+
namespace App;
27+
28+
use Illuminate\Notifications\Notifiable;
29+
use StevePorter92\Mongodb\Auth\User as Authenticatable;
30+
31+
class User extends Authenticatable
32+
{
33+
use Notifiable;
34+
}
35+
```
36+
2137
### Laravel version Compatibility
2238

2339
Laravel | Package
@@ -36,4 +52,4 @@ For usage with [Lumen](http://lumen.laravel.com), add the service provider in `b
3652
$app->register(StevePorter92\Mongodb\MongodbPassportServiceProvider::class);
3753
```
3854

39-
The service provider will overide the default laravel passport models in order to use mongodb's implementation of eloquent. There is no need to register any additional classes or add any additional configuration other than those outlined in [Laravel Passport](https://github.com/laravel/passport) and [MongoDB](https://github.com/jenssegers/laravel-mongodb).
55+
The service provider will overide the default laravel passport models in order to use mongodb's implementation of eloquent. There is no need to register any additional classes or add any additional configuration other than those outlined in [Laravel Passport](https://github.com/laravel/passport) and [MongoDB](https://github.com/jenssegers/laravel-mongodb).

src/Auth/User.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace StevePorter92\Mongodb\Auth;
4+
5+
use Illuminate\Auth\Authenticatable;
6+
use Illuminate\Auth\Passwords\CanResetPassword;
7+
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
8+
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
9+
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
10+
use Illuminate\Foundation\Auth\Access\Authorizable;
11+
use Jenssegers\Mongodb\Eloquent\Model;
12+
use Laravel\Passport\HasApiTokens;
13+
14+
class User extends Model implements
15+
AuthenticatableContract,
16+
AuthorizableContract,
17+
CanResetPasswordContract
18+
{
19+
use Authenticatable, Authorizable, CanResetPassword, HasApiTokens;
20+
}

0 commit comments

Comments
 (0)