Skip to content

Commit 622037f

Browse files
Merge pull request #39 from leolleocomp/master
Add RefreshToken model to the list aliases
2 parents 7168c39 + 61ab322 commit 622037f

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

src/MongodbPassportServiceProvider.php

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use DesignMyNight\Mongodb\Passport\AuthCode;
77
use DesignMyNight\Mongodb\Passport\Client;
88
use DesignMyNight\Mongodb\Passport\PersonalAccessClient;
9+
use DesignMyNight\Mongodb\Passport\RefreshToken;
910
use DesignMyNight\Mongodb\Passport\Token;
1011

1112
class MongodbPassportServiceProvider extends ServiceProvider
@@ -21,11 +22,13 @@ public function register()
2122
$loader->alias('Laravel\Passport\Client', Client::class);
2223
$loader->alias('Laravel\Passport\PersonalAccessClient', PersonalAccessClient::class);
2324
$loader->alias('Laravel\Passport\Token', Token::class);
25+
$loader->alias('Laravel\Passport\RefreshToken', RefreshToken::class);
2426
} else {
2527
class_alias('Laravel\Passport\AuthCode', AuthCode::class);
2628
class_alias('Laravel\Passport\Client', Client::class);
2729
class_alias('Laravel\Passport\PersonalAccessClient', PersonalAccessClient::class);
2830
class_alias('Laravel\Passport\Token', Token::class);
31+
class_alias('Laravel\Passport\RefreshToken', RefreshToken::class);
2932
}
3033
}
3134
}

src/Passport/RefreshToken.php

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
namespace DesignMyNight\Mongodb\Passport;
4+
5+
use Jenssegers\Mongodb\Eloquent\Model;
6+
7+
class RefreshToken extends Model
8+
{
9+
/**
10+
* The database table used by the model.
11+
*
12+
* @var string
13+
*/
14+
protected $table = 'oauth_refresh_tokens';
15+
16+
/**
17+
* Indicates if the IDs are auto-incrementing.
18+
*
19+
* @var bool
20+
*/
21+
public $incrementing = false;
22+
23+
/**
24+
* The guarded attributes on the model.
25+
*
26+
* @var array
27+
*/
28+
protected $guarded = [];
29+
30+
/**
31+
* The attributes that should be cast to native types.
32+
*
33+
* @var array
34+
*/
35+
protected $casts = [
36+
'revoked' => 'bool',
37+
];
38+
39+
/**
40+
* The attributes that should be mutated to dates.
41+
*
42+
* @var array
43+
*/
44+
protected $dates = [
45+
'expires_at',
46+
];
47+
48+
/**
49+
* Indicates if the model should be timestamped.
50+
*
51+
* @var bool
52+
*/
53+
public $timestamps = false;
54+
55+
/**
56+
* Get the access token that the refresh token belongs to.
57+
*
58+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
59+
*/
60+
public function accessToken()
61+
{
62+
return $this->belongsTo(Passport::tokenModel());
63+
}
64+
65+
/**
66+
* Revoke the token instance.
67+
*
68+
* @return bool
69+
*/
70+
public function revoke()
71+
{
72+
return $this->forceFill(['revoked' => true])->save();
73+
}
74+
75+
/**
76+
* Determine if the token is a transient JWT token.
77+
*
78+
* @return bool
79+
*/
80+
public function transient()
81+
{
82+
return false;
83+
}
84+
}

0 commit comments

Comments
 (0)