API key UI changes and backend storage of the keys

This commit is contained in:
Dane Everitt 2017-11-19 13:32:17 -06:00
parent 69e67b5e2d
commit 47e14ccaae
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
11 changed files with 136 additions and 160 deletions

View file

@ -19,6 +19,8 @@ class APIKey extends Model implements CleansAttributes, ValidableContract
{
use Eloquence, Validable;
const KEY_LENGTH = 32;
/**
* The table associated with the model.
*
@ -26,13 +28,6 @@ class APIKey extends Model implements CleansAttributes, ValidableContract
*/
protected $table = 'api_keys';
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['secret'];
/**
* Cast values to correct type.
*
@ -57,8 +52,7 @@ class APIKey extends Model implements CleansAttributes, ValidableContract
protected static $applicationRules = [
'memo' => 'required',
'user_id' => 'required',
'secret' => 'required',
'public' => 'required',
'token' => 'required',
];
/**
@ -68,8 +62,7 @@ class APIKey extends Model implements CleansAttributes, ValidableContract
*/
protected static $dataIntegrityRules = [
'user_id' => 'exists:users,id',
'public' => 'string|size:16',
'secret' => 'string',
'token' => 'string|size:32',
'memo' => 'nullable|string|max:500',
'allowed_ips' => 'nullable|json',
'expires_at' => 'nullable|datetime',