File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
-
3
2
namespace App \Providers ;
4
3
4
+ use Carbon \Carbon ;
5
5
use Illuminate \Support \Facades \Gate ;
6
+ use Laravel \Passport \Passport ;
6
7
use Illuminate \Foundation \Support \Providers \AuthServiceProvider as ServiceProvider ;
7
8
8
9
class AuthServiceProvider extends ServiceProvider
9
10
{
11
+
10
12
/**
11
13
* The policy mappings for the application.
12
14
*
13
15
* @var array
14
16
*/
15
17
protected $ policies = [
16
- 'App\Model ' => 'App\Policies\ModelPolicy ' ,
18
+ 'App\Model ' => 'App\Policies\ModelPolicy '
17
19
];
18
20
19
21
/**
@@ -25,6 +27,13 @@ public function boot()
25
27
{
26
28
$ this ->registerPolicies ();
27
29
28
- //
30
+ Passport::routes (function ($ router ) {
31
+ $ router ->forAccessTokens ();
32
+ $ router ->forPersonalAccessTokens ();
33
+ $ router ->forTransientTokens ();
34
+ });
35
+
36
+ Passport::tokensExpireIn (Carbon::now ()->addMinutes (10 ));
37
+ Passport::refreshTokensExpireIn (Carbon::now ()->addDays (10 ));
29
38
}
30
39
}
Original file line number Diff line number Diff line change 4
4
5
5
use Illuminate \Notifications \Notifiable ;
6
6
use Illuminate \Foundation \Auth \User as Authenticatable ;
7
+ use Laravel \Passport \HasApiTokens ;
7
8
8
9
class User extends Authenticatable
9
10
{
10
- use Notifiable;
11
+ use HasApiTokens, Notifiable;
11
12
12
13
/**
13
14
* The attributes that are mass assignable.
Original file line number Diff line number Diff line change 42
42
],
43
43
44
44
'api ' => [
45
- 'driver ' => 'token ' ,
45
+ 'driver ' => 'passport ' ,
46
46
'provider ' => 'users ' ,
47
47
],
48
48
],
You can’t perform that action at this time.
0 commit comments