mirror of
https://github.com/flarum/core.git
synced 2025-10-11 23:14:29 +02:00
[b8] master token fix (#1622)
* fixed not being able to use master token because id column no longer holds key * added flexibility of user_id column * added tests to confirm the api keys actually work as intended
This commit is contained in:
committed by
Franz Liedke
parent
fb185f70cd
commit
bb0fc165af
@@ -11,7 +11,9 @@
|
||||
|
||||
namespace Flarum\Api;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Flarum\Database\AbstractModel;
|
||||
use Flarum\User\User;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
@@ -19,11 +21,14 @@ use Flarum\Database\AbstractModel;
|
||||
* @property string|null $allowed_ips
|
||||
* @property string|null $scopes
|
||||
* @property int|null $user_id
|
||||
* @property \Flarum\User\User|null $user
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon|null $last_activity_at
|
||||
*/
|
||||
class ApiKey extends AbstractModel
|
||||
{
|
||||
protected $dates = ['last_activity_at'];
|
||||
|
||||
/**
|
||||
* Generate an API key.
|
||||
*
|
||||
@@ -37,4 +42,16 @@ class ApiKey extends AbstractModel
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
public function touch()
|
||||
{
|
||||
$this->last_activity_at = Carbon::now();
|
||||
|
||||
return $this->save();
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user