fix: service status indicator + oauth saving

This commit is contained in:
Andras Bacsai
2024-12-13 12:03:05 +01:00
parent 2a77d9d8ce
commit 4901b12279
11 changed files with 47 additions and 36 deletions

View File

@@ -11,6 +11,8 @@ class OauthSetting extends Model
{
use HasFactory;
protected $fillable = ['provider', 'client_id', 'client_secret', 'redirect_uri', 'tenant', 'base_url', 'enabled'];
protected function clientSecret(): Attribute
{
return Attribute::make(
@@ -18,4 +20,16 @@ class OauthSetting extends Model
set: fn (?string $value) => empty($value) ? null : Crypt::encryptString($value),
);
}
public function couldBeEnabled(): bool
{
switch ($this->provider) {
case 'azure':
return filled($this->client_id) && filled($this->client_secret) && filled($this->redirect_uri) && filled($this->tenant);
case 'authentik':
return filled($this->client_id) && filled($this->client_secret) && filled($this->redirect_uri) && filled($this->base_url);
default:
return filled($this->client_id) && filled($this->client_secret) && filled($this->redirect_uri);
}
}
}