Add missing user timezone stuff (#446)

This commit is contained in:
Boy132 2024-06-29 23:42:46 +02:00 committed by GitHub
parent 82c0568129
commit 133b94ab08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -25,6 +25,7 @@ class StoreUserRequest extends ApplicationApiRequest
'username',
'password',
'language',
'timezone',
'root_admin',
])->toArray();

View File

@ -5,6 +5,7 @@ namespace App\Models;
use App\Exceptions\DisplayException;
use App\Rules\Username;
use App\Facades\Activity;
use DateTimeZone;
use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasAvatar;
use Filament\Models\Contracts\HasName;
@ -38,6 +39,7 @@ use App\Notifications\SendPasswordReset as ResetPasswordNotification;
* @property string $password
* @property string|null $remember_token
* @property string $language
* @property string $timezone
* @property bool $root_admin
* @property bool $use_totp
* @property string|null $totp_secret
@ -70,6 +72,7 @@ use App\Notifications\SendPasswordReset as ResetPasswordNotification;
* @method static Builder|User whereGravatar($value)
* @method static Builder|User whereId($value)
* @method static Builder|User whereLanguage($value)
* @method static Builder|User whereTimezone($value)
* @method static Builder|User whereNameFirst($value)
* @method static Builder|User whereNameLast($value)
* @method static Builder|User wherePassword($value)
@ -144,6 +147,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
'external_id' => null,
'root_admin' => false,
'language' => 'en',
'timezone' => 'UTC',
'use_totp' => false,
'totp_secret' => null,
'name_first' => '',
@ -164,6 +168,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
'password' => 'sometimes|nullable|string',
'root_admin' => 'boolean',
'language' => 'string',
'timezone' => 'string',
'use_totp' => 'boolean',
'totp_secret' => 'nullable|string',
'oauth' => 'array|nullable',
@ -210,6 +215,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
$rules = parent::getRules();
$rules['language'][] = new In(array_keys((new self())->getAvailableLanguages()));
$rules['timezone'][] = new In(array_values(DateTimeZone::listIdentifiers()));
$rules['username'][] = new Username();
return $rules;