mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 21:04:44 +02:00
Update users
This commit is contained in:
parent
039ac40cf7
commit
03e1733b7d
@ -25,42 +25,14 @@ class UserResource extends Resource
|
|||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\TextInput::make('external_id')
|
Forms\Components\TextInput::make('username')->required()->maxLength(191),
|
||||||
->maxLength(191),
|
Forms\Components\TextInput::make('email')->email()->required()->maxLength(191),
|
||||||
Forms\Components\TextInput::make('uuid')
|
Forms\Components\TextInput::make('name_first')->maxLength(191),
|
||||||
->label('UUID')
|
Forms\Components\TextInput::make('name_last')->maxLength(191),
|
||||||
->required()
|
Forms\Components\TextInput::make('password')->password()->columnSpanFull(),
|
||||||
->maxLength(36),
|
Forms\Components\Select::make('language')->required()->default('en')
|
||||||
Forms\Components\TextInput::make('username')
|
->options(fn (User $user) => $user->getAvailableLanguages()),
|
||||||
->required()
|
Forms\Components\Toggle::make('root_admin')->required()->default(0),
|
||||||
->maxLength(191),
|
|
||||||
Forms\Components\TextInput::make('email')
|
|
||||||
->email()
|
|
||||||
->required()
|
|
||||||
->maxLength(191),
|
|
||||||
Forms\Components\TextInput::make('name_first')
|
|
||||||
->maxLength(191),
|
|
||||||
Forms\Components\TextInput::make('name_last')
|
|
||||||
->maxLength(191),
|
|
||||||
Forms\Components\Textarea::make('password')
|
|
||||||
->required()
|
|
||||||
->columnSpanFull(),
|
|
||||||
Forms\Components\TextInput::make('language')
|
|
||||||
->required()
|
|
||||||
->maxLength(5)
|
|
||||||
->default('en'),
|
|
||||||
Forms\Components\TextInput::make('root_admin')
|
|
||||||
->required()
|
|
||||||
->numeric()
|
|
||||||
->default(0),
|
|
||||||
Forms\Components\TextInput::make('use_totp')
|
|
||||||
->required()
|
|
||||||
->numeric(),
|
|
||||||
Forms\Components\Textarea::make('totp_secret')
|
|
||||||
->columnSpanFull(),
|
|
||||||
Forms\Components\DateTimePicker::make('totp_authenticated_at'),
|
|
||||||
Forms\Components\Toggle::make('gravatar')
|
|
||||||
->required(),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,32 +40,32 @@ class UserResource extends Resource
|
|||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
->columns([
|
->columns([
|
||||||
|
Tables\Columns\ImageColumn::make('picture')
|
||||||
|
->defaultImageUrl(fn (User $user) => 'https://gravatar.com/avatar/' . md5(strtolower($user->email))),
|
||||||
Tables\Columns\TextColumn::make('external_id')
|
Tables\Columns\TextColumn::make('external_id')
|
||||||
->searchable(),
|
->searchable()
|
||||||
|
->hidden(),
|
||||||
Tables\Columns\TextColumn::make('uuid')
|
Tables\Columns\TextColumn::make('uuid')
|
||||||
->label('UUID')
|
->label('UUID')
|
||||||
|
->hidden()
|
||||||
->searchable(),
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('username')
|
Tables\Columns\TextColumn::make('username')
|
||||||
->searchable(),
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('email')
|
Tables\Columns\TextColumn::make('email')->searchable(),
|
||||||
->searchable(),
|
Tables\Columns\TextColumn::make('name')->searchable(),
|
||||||
Tables\Columns\TextColumn::make('name_first')
|
Tables\Columns\IconColumn::make('root_admin')->label('Admin')->boolean()->sortable(),
|
||||||
->searchable(),
|
Tables\Columns\IconColumn::make('use_totp')->label('2FA')
|
||||||
Tables\Columns\TextColumn::make('name_last')
|
->icon(fn (User $user) => $user->use_totp ? 'heroicon-o-lock-closed' : 'heroicon-o-lock-open')
|
||||||
->searchable(),
|
->boolean()->sortable(),
|
||||||
Tables\Columns\TextColumn::make('language')
|
Tables\Columns\TextColumn::make('servers_count')
|
||||||
->searchable(),
|
->counts('servers')
|
||||||
Tables\Columns\TextColumn::make('root_admin')
|
->icon('heroicon-m-server-stack')
|
||||||
->numeric()
|
->label('Servers Owned'),
|
||||||
->sortable(),
|
Tables\Columns\TextColumn::make('subusers_count')
|
||||||
Tables\Columns\TextColumn::make('use_totp')
|
->counts('subusers')
|
||||||
->numeric()
|
->icon('heroicon-m-users')
|
||||||
->sortable(),
|
// ->formatStateUsing(fn (string $state, $record): string => (string) ($record->servers_count + $record->subusers_count))
|
||||||
Tables\Columns\TextColumn::make('totp_authenticated_at')
|
->label('Subusers'),
|
||||||
->dateTime()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\IconColumn::make('gravatar')
|
|
||||||
->boolean(),
|
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
|
@ -179,6 +179,11 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRouteKeyName(): string
|
||||||
|
{
|
||||||
|
return 'id';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement language verification by overriding Eloquence's gather
|
* Implement language verification by overriding Eloquence's gather
|
||||||
* rules function.
|
* rules function.
|
||||||
@ -280,6 +285,11 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
|
|||||||
->groupBy('servers.id');
|
->groupBy('servers.id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function subusers(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Subuser::class);
|
||||||
|
}
|
||||||
|
|
||||||
protected function checkPermission(Server $server, string $permission = ''): bool
|
protected function checkPermission(Server $server, string $permission = ''): bool
|
||||||
{
|
{
|
||||||
if ($this->root_admin || $server->owner_id === $this->id) {
|
if ($this->root_admin || $server->owner_id === $this->id) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user