Cleanup frontend to only pass the required description field
This commit is contained in:
parent
374910d73a
commit
dfff8ad667
4 changed files with 30 additions and 27 deletions
|
@ -9,6 +9,11 @@ class PersonalAccessToken extends Model implements HasAbilities
|
|||
{
|
||||
public const RESOURCE_NAME = 'personal_access_token';
|
||||
|
||||
/**
|
||||
* The length of the raw API token.
|
||||
*/
|
||||
public const TOKEN_LENGTH = 32;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
|
@ -28,6 +33,16 @@ class PersonalAccessToken extends Model implements HasAbilities
|
|||
'abilities',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public static array $validationRules = [
|
||||
'token' => 'required|string',
|
||||
'token_id' => 'required|string|size:16',
|
||||
'description' => 'required|nullable|string|max:500',
|
||||
'last_used_at' => 'nullable|date',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
|
@ -87,4 +102,14 @@ class PersonalAccessToken extends Model implements HasAbilities
|
|||
|
||||
return static::where('token_id', $id)->where('token', hash('sha256', $token))->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new identifier for a personal access token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function generateTokenIdentifier(): string
|
||||
{
|
||||
return 'ptdl_' . Str::random(11);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue