feat: add Discord facade
This commit is contained in:
47
app/User.php
47
app/User.php
@@ -42,7 +42,19 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password', 'originalIP', 'username', 'uuid', 'dob',
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'originalIP',
|
||||
'registrationIp',
|
||||
'username',
|
||||
'uuid',
|
||||
'dob',
|
||||
'email_verified_at',
|
||||
'currentIp',
|
||||
'discord_user_id',
|
||||
'discord_token',
|
||||
'discord_refresh_token'
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -51,7 +63,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
'password', 'remember_token', 'discord_token', 'discord_refresh_token'
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -61,6 +73,8 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
'discord_token' => 'encrypted',
|
||||
'discord_refresh_token' => 'encrypted'
|
||||
];
|
||||
|
||||
// RELATIONSHIPS
|
||||
@@ -101,35 +115,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
return $this->hasMany('App\Absence', 'requesterID');
|
||||
}
|
||||
|
||||
|
||||
// ACCESSORS AND MUTATORS
|
||||
|
||||
/**
|
||||
* Encrypt/decrypt the Discord access token. Data is encrypted at rest.
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
public function discordToken(): Attribute {
|
||||
return Attribute::make(
|
||||
get: fn ($value) => Crypt::decryptString($value),
|
||||
set: fn ($value) => Crypt::encryptString($value)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt/decrypt the Discord refresh token. Data is encrypted at rest.
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
public function discordRefreshToken(): Attribute {
|
||||
return Attribute::make(
|
||||
get: fn ($value) => Crypt::decryptString($value),
|
||||
set: fn ($value) => Crypt::encryptString($value)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// UTILITY LOGIC
|
||||
|
||||
public function isVerified(): bool {
|
||||
|
Reference in New Issue
Block a user