2015-12-06 13:58:49 -05:00
|
|
|
<?php
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2024-03-12 22:39:16 -04:00
|
|
|
namespace App\Models;
|
2015-12-06 13:58:49 -05:00
|
|
|
|
2025-01-30 16:39:00 -05:00
|
|
|
use App\Contracts\Validatable;
|
2025-09-08 13:12:33 -04:00
|
|
|
use App\Enums\CustomizationKey;
|
2024-03-18 21:23:13 -04:00
|
|
|
use App\Exceptions\DisplayException;
|
2025-07-01 21:33:11 -04:00
|
|
|
use App\Extensions\Avatar\AvatarService;
|
2025-09-24 13:34:19 +02:00
|
|
|
use App\Models\Traits\HasAccessTokens;
|
2025-01-30 16:39:00 -05:00
|
|
|
use App\Traits\HasValidation;
|
2025-09-24 13:34:19 +02:00
|
|
|
use BackedEnum;
|
|
|
|
|
use Database\Factories\UserFactory;
|
2024-06-29 23:42:46 +02:00
|
|
|
use DateTimeZone;
|
2025-09-24 13:34:19 +02:00
|
|
|
use Filament\Auth\MultiFactor\App\Contracts\HasAppAuthentication;
|
|
|
|
|
use Filament\Auth\MultiFactor\App\Contracts\HasAppAuthenticationRecovery;
|
|
|
|
|
use Filament\Auth\MultiFactor\Email\Contracts\HasEmailAuthentication;
|
2024-03-23 20:17:48 -04:00
|
|
|
use Filament\Models\Contracts\FilamentUser;
|
2025-09-24 13:34:19 +02:00
|
|
|
use Filament\Models\Contracts\HasAvatar;
|
2024-04-06 10:11:10 -04:00
|
|
|
use Filament\Models\Contracts\HasName;
|
feat: Client UI translate to Filament (from React) (#416)
* Add new panel
* Add some basic resource pages
* Wip
* Wip terminal
* Wip
* Add new panel
* Add some basic resource pages
* Wip
* [Sub-Users] Add Invite
TODO: The logic with permissions
* [Sub-Users] Fix Creation
* [Cron] Add basics
* Add basic auth and messages
* Add basic buttons
* WIP on issue/353
* WIP on issue/353
* Add Database page
* Update Database Page
* Start of Backup Page
* Composer Update
* Changes
* Send input
* Remove this includes
* Better offline handling
* Consolidate top nav config
* Update Backups Page
* Update Backups
* Change name
* Add Assign All, Layout Fixes.
* conflict
* update schedule pages
* fix phpstan
* update pint.json
* add cron presets to schedule
* fix tests
* fix task creation
* schedules: disable task creation if limit is reached & disable backup action if backup limit is 0
* update activity pages
* update resources
* Update Edit User
TODO: actually save permissions when they're changed.
TODO: Figure out why Control does not update it's state... but the rest do...
* .... Sure it works.
TODO: Update permissions when you save editing a sub user.
* user: update canAccessPanel & canAccessTenant
* add helper to convert bytes into readable format
* very basic file explorer
* files: fix some stuff & remove dummy data
* files: better error handling
* files: basic file editor
* files: add some actions
* File manager updates
* files: fix paths
* Revery Composer Upgrade, Fixes SQLite
* fix: Pint (#517)
feat: MenuItems to and from admin
* Update File Editing
Updated File Editing to its own page,
Added Permission checks for file manager.
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
* add enum for editor langs
* files: add upload & pull actions
* fix build
* files: handle images
* Update to Filament v3.2.98
* files: add remaining actions
* use `authorize` instead of `hidden`
* fix canAccessTenant
* update date columns
* files: testing & fixes
* Fix File Names
Co-authored-by: lancepioch <git@lance.sh>
* Combine Pull/Upload
* Fix BulkDelete
* Uncontained tabs
* Hide Lang Selection, Move Actions
* Update Monaco, more custom
* Add livewire config
livewire limits uploads to 12MB... who knows why...
Fixed uploading a single files failing
* files: fix record url
* basic setup for settings & startup page
* make abstract class for simple app pages
* Basic Startup Page
* Update nav sort
* small cleanup
* startup: fix shouldHideComponent & getSelectOptionsFromRules
* startup: fix non editable fields & set default value
* startup: add todo for save button
* Save Variables after update & off click
Variables update when the user clicks off the input.
* Notifications are cool
* Add rule validation
* Sort variables by sortid
* pint
* Settings Page + Startup Changes
* settings: cleanup
* refactor: use server model for ServerFormPage (formerly known as SimplePage)
* Use Repeater for variables
* Add Network, Remove breadcrumbs
* Add paginated to file explorer
* Fix updating variables
* Add link to go to new client area
* fix after merge
* Add graphs to console page
Graphs still need to get the data from the web socket.
* fix pint & phpstan
* fix authorizeAccess for EditFiles and Startup page
* Fix rules on startup page
* Update console size
* Fix node name
* add "global search" to files list
requires https://github.com/pelican-dev/wings/pull/44
* remove debug dummy data
* update view action on ListServers
* enable SPA mode for app panel
* remove colors from app panel
they are defined globally in AppServiceProvider
* update global search ui a bit
(to be replaced with a custom page that is similar to the list files table)
* add own page for global search
untested - and route needs cleanup (if possible)
* fix File getRows
* remove "path" from SearchFiles (for now)
* fix caching for searched files
* add title and breadcrumbs to global search page
* make cpu & memory charts on console page working
* fix phpstan
* add missing import
* cleanup console views & widgets
* add overview stats to console
* don't be so lazy, console!
* make history working
* decode data to get array
* add missing On
* fix json_decode
* change polling to 1 sec
* hide "0" cpu/ memory
* add data to network chart
* Remove data labels
* fix data on network chart
* fix data on network chart (2nd try)
* WIP Network Stats
* Remove test
* Change MaxWidth
* run pint
* fix phpstan
* Fix storeStats cast
* make $data a string
this time for real
* update visible check for "admin" menu item
* remove account widget
* rebrand "Dashboard" to "Server List"
WIP - doesn't look good but is somewhat working
* fix canAccessPanel
* separate server list into own panel
* change path to avoid conflicts with old client area (and remove sidebar width)
* display correct icon and color on server list entries
* show total memory if server is offline
* replace custom server list page with ListRecords page
* fix tests
* fix namespace
* remove "open" button and make whole column clickable
* Update EditProfile
* run pint
* fix access to server list
* add new login page to panels
* fix next_run_at for new schedules
* use new DateTimeColumn
* add own column for file bytes
* return to server list when clicking title
* fix console loading
* handle server with "conflict state"
* add banner if server is in "conflict state"
* fix phpstan
* update docker image select
* fix permission checks on Settings & Startup pages
* fix query for activity log page
* fix activity log not being logged
* adjust ListActivities
* fix phpstan
* fix pint
* fix profile menu item link on server panel
* add ip tooltip to activity logs (and role permission)
* change backup icon
* update navigation sort
* general code cleanup
* more cleanup
* Disable Restart/Stop if server is offline
* Change rename notification
* Remove negation on abort_unless
* Add notification on save
* Single disabled closure & comment unused import
* Add required to Server Name & Nullable to description
* mutateFormDataBeforeSave doesn't work since we use forceFill
* Fix web socket connection not existing.
* Fix some subuser permissions
* add permission checks to resources
* do not allow self-deletion
* Update editing file permissions
* Fix of the previous fix
* add service for subuser updating
* Only allow save if they have file_update
* Remove unused import
* Update backup delete button
* Add Delete, remove bulks
* Update Database page
* Use Allocation Permissions
* add canAccess check to startup
* Add Permission checks to Settings page
* add service for subuser deletion
* Remove Kill permission
* Updates
* fix move files
* add redirects
* fix phpstan
* activity: remove properties from tans for now
* If alias, use that, else ip
---------
Co-authored-by: notCharles <charles@pelican.dev>
Co-authored-by: Boy132 <mail@boy132.de>
Co-authored-by: Senna <62171904+Poseidon281@users.noreply.github.com>
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
2024-11-30 22:13:45 -05:00
|
|
|
use Filament\Models\Contracts\HasTenants;
|
2024-03-23 20:17:48 -04:00
|
|
|
use Filament\Panel;
|
2025-09-24 13:34:19 +02:00
|
|
|
use Illuminate\Auth\Authenticatable;
|
|
|
|
|
use Illuminate\Auth\Passwords\CanResetPassword;
|
|
|
|
|
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
|
|
|
|
|
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
|
|
|
|
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
2025-03-03 14:41:19 -05:00
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
2025-01-30 16:39:00 -05:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
feat: Client UI translate to Filament (from React) (#416)
* Add new panel
* Add some basic resource pages
* Wip
* Wip terminal
* Wip
* Add new panel
* Add some basic resource pages
* Wip
* [Sub-Users] Add Invite
TODO: The logic with permissions
* [Sub-Users] Fix Creation
* [Cron] Add basics
* Add basic auth and messages
* Add basic buttons
* WIP on issue/353
* WIP on issue/353
* Add Database page
* Update Database Page
* Start of Backup Page
* Composer Update
* Changes
* Send input
* Remove this includes
* Better offline handling
* Consolidate top nav config
* Update Backups Page
* Update Backups
* Change name
* Add Assign All, Layout Fixes.
* conflict
* update schedule pages
* fix phpstan
* update pint.json
* add cron presets to schedule
* fix tests
* fix task creation
* schedules: disable task creation if limit is reached & disable backup action if backup limit is 0
* update activity pages
* update resources
* Update Edit User
TODO: actually save permissions when they're changed.
TODO: Figure out why Control does not update it's state... but the rest do...
* .... Sure it works.
TODO: Update permissions when you save editing a sub user.
* user: update canAccessPanel & canAccessTenant
* add helper to convert bytes into readable format
* very basic file explorer
* files: fix some stuff & remove dummy data
* files: better error handling
* files: basic file editor
* files: add some actions
* File manager updates
* files: fix paths
* Revery Composer Upgrade, Fixes SQLite
* fix: Pint (#517)
feat: MenuItems to and from admin
* Update File Editing
Updated File Editing to its own page,
Added Permission checks for file manager.
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
* add enum for editor langs
* files: add upload & pull actions
* fix build
* files: handle images
* Update to Filament v3.2.98
* files: add remaining actions
* use `authorize` instead of `hidden`
* fix canAccessTenant
* update date columns
* files: testing & fixes
* Fix File Names
Co-authored-by: lancepioch <git@lance.sh>
* Combine Pull/Upload
* Fix BulkDelete
* Uncontained tabs
* Hide Lang Selection, Move Actions
* Update Monaco, more custom
* Add livewire config
livewire limits uploads to 12MB... who knows why...
Fixed uploading a single files failing
* files: fix record url
* basic setup for settings & startup page
* make abstract class for simple app pages
* Basic Startup Page
* Update nav sort
* small cleanup
* startup: fix shouldHideComponent & getSelectOptionsFromRules
* startup: fix non editable fields & set default value
* startup: add todo for save button
* Save Variables after update & off click
Variables update when the user clicks off the input.
* Notifications are cool
* Add rule validation
* Sort variables by sortid
* pint
* Settings Page + Startup Changes
* settings: cleanup
* refactor: use server model for ServerFormPage (formerly known as SimplePage)
* Use Repeater for variables
* Add Network, Remove breadcrumbs
* Add paginated to file explorer
* Fix updating variables
* Add link to go to new client area
* fix after merge
* Add graphs to console page
Graphs still need to get the data from the web socket.
* fix pint & phpstan
* fix authorizeAccess for EditFiles and Startup page
* Fix rules on startup page
* Update console size
* Fix node name
* add "global search" to files list
requires https://github.com/pelican-dev/wings/pull/44
* remove debug dummy data
* update view action on ListServers
* enable SPA mode for app panel
* remove colors from app panel
they are defined globally in AppServiceProvider
* update global search ui a bit
(to be replaced with a custom page that is similar to the list files table)
* add own page for global search
untested - and route needs cleanup (if possible)
* fix File getRows
* remove "path" from SearchFiles (for now)
* fix caching for searched files
* add title and breadcrumbs to global search page
* make cpu & memory charts on console page working
* fix phpstan
* add missing import
* cleanup console views & widgets
* add overview stats to console
* don't be so lazy, console!
* make history working
* decode data to get array
* add missing On
* fix json_decode
* change polling to 1 sec
* hide "0" cpu/ memory
* add data to network chart
* Remove data labels
* fix data on network chart
* fix data on network chart (2nd try)
* WIP Network Stats
* Remove test
* Change MaxWidth
* run pint
* fix phpstan
* Fix storeStats cast
* make $data a string
this time for real
* update visible check for "admin" menu item
* remove account widget
* rebrand "Dashboard" to "Server List"
WIP - doesn't look good but is somewhat working
* fix canAccessPanel
* separate server list into own panel
* change path to avoid conflicts with old client area (and remove sidebar width)
* display correct icon and color on server list entries
* show total memory if server is offline
* replace custom server list page with ListRecords page
* fix tests
* fix namespace
* remove "open" button and make whole column clickable
* Update EditProfile
* run pint
* fix access to server list
* add new login page to panels
* fix next_run_at for new schedules
* use new DateTimeColumn
* add own column for file bytes
* return to server list when clicking title
* fix console loading
* handle server with "conflict state"
* add banner if server is in "conflict state"
* fix phpstan
* update docker image select
* fix permission checks on Settings & Startup pages
* fix query for activity log page
* fix activity log not being logged
* adjust ListActivities
* fix phpstan
* fix pint
* fix profile menu item link on server panel
* add ip tooltip to activity logs (and role permission)
* change backup icon
* update navigation sort
* general code cleanup
* more cleanup
* Disable Restart/Stop if server is offline
* Change rename notification
* Remove negation on abort_unless
* Add notification on save
* Single disabled closure & comment unused import
* Add required to Server Name & Nullable to description
* mutateFormDataBeforeSave doesn't work since we use forceFill
* Fix web socket connection not existing.
* Fix some subuser permissions
* add permission checks to resources
* do not allow self-deletion
* Update editing file permissions
* Fix of the previous fix
* add service for subuser updating
* Only allow save if they have file_update
* Remove unused import
* Update backup delete button
* Add Delete, remove bulks
* Update Database page
* Use Allocation Permissions
* add canAccess check to startup
* Add Permission checks to Settings page
* add service for subuser deletion
* Remove Kill permission
* Updates
* fix move files
* add redirects
* fix phpstan
* activity: remove properties from tans for now
* If alias, use that, else ip
---------
Co-authored-by: notCharles <charles@pelican.dev>
Co-authored-by: Boy132 <mail@boy132.de>
Co-authored-by: Senna <62171904+Poseidon281@users.noreply.github.com>
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
2024-11-30 22:13:45 -05:00
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
2025-09-24 13:34:19 +02:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
|
|
|
|
use Illuminate\Foundation\Auth\Access\Authorizable;
|
|
|
|
|
use Illuminate\Notifications\DatabaseNotification;
|
|
|
|
|
use Illuminate\Notifications\DatabaseNotificationCollection;
|
|
|
|
|
use Illuminate\Notifications\Notifiable;
|
|
|
|
|
use Illuminate\Support\Carbon;
|
feat: Client UI translate to Filament (from React) (#416)
* Add new panel
* Add some basic resource pages
* Wip
* Wip terminal
* Wip
* Add new panel
* Add some basic resource pages
* Wip
* [Sub-Users] Add Invite
TODO: The logic with permissions
* [Sub-Users] Fix Creation
* [Cron] Add basics
* Add basic auth and messages
* Add basic buttons
* WIP on issue/353
* WIP on issue/353
* Add Database page
* Update Database Page
* Start of Backup Page
* Composer Update
* Changes
* Send input
* Remove this includes
* Better offline handling
* Consolidate top nav config
* Update Backups Page
* Update Backups
* Change name
* Add Assign All, Layout Fixes.
* conflict
* update schedule pages
* fix phpstan
* update pint.json
* add cron presets to schedule
* fix tests
* fix task creation
* schedules: disable task creation if limit is reached & disable backup action if backup limit is 0
* update activity pages
* update resources
* Update Edit User
TODO: actually save permissions when they're changed.
TODO: Figure out why Control does not update it's state... but the rest do...
* .... Sure it works.
TODO: Update permissions when you save editing a sub user.
* user: update canAccessPanel & canAccessTenant
* add helper to convert bytes into readable format
* very basic file explorer
* files: fix some stuff & remove dummy data
* files: better error handling
* files: basic file editor
* files: add some actions
* File manager updates
* files: fix paths
* Revery Composer Upgrade, Fixes SQLite
* fix: Pint (#517)
feat: MenuItems to and from admin
* Update File Editing
Updated File Editing to its own page,
Added Permission checks for file manager.
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
* add enum for editor langs
* files: add upload & pull actions
* fix build
* files: handle images
* Update to Filament v3.2.98
* files: add remaining actions
* use `authorize` instead of `hidden`
* fix canAccessTenant
* update date columns
* files: testing & fixes
* Fix File Names
Co-authored-by: lancepioch <git@lance.sh>
* Combine Pull/Upload
* Fix BulkDelete
* Uncontained tabs
* Hide Lang Selection, Move Actions
* Update Monaco, more custom
* Add livewire config
livewire limits uploads to 12MB... who knows why...
Fixed uploading a single files failing
* files: fix record url
* basic setup for settings & startup page
* make abstract class for simple app pages
* Basic Startup Page
* Update nav sort
* small cleanup
* startup: fix shouldHideComponent & getSelectOptionsFromRules
* startup: fix non editable fields & set default value
* startup: add todo for save button
* Save Variables after update & off click
Variables update when the user clicks off the input.
* Notifications are cool
* Add rule validation
* Sort variables by sortid
* pint
* Settings Page + Startup Changes
* settings: cleanup
* refactor: use server model for ServerFormPage (formerly known as SimplePage)
* Use Repeater for variables
* Add Network, Remove breadcrumbs
* Add paginated to file explorer
* Fix updating variables
* Add link to go to new client area
* fix after merge
* Add graphs to console page
Graphs still need to get the data from the web socket.
* fix pint & phpstan
* fix authorizeAccess for EditFiles and Startup page
* Fix rules on startup page
* Update console size
* Fix node name
* add "global search" to files list
requires https://github.com/pelican-dev/wings/pull/44
* remove debug dummy data
* update view action on ListServers
* enable SPA mode for app panel
* remove colors from app panel
they are defined globally in AppServiceProvider
* update global search ui a bit
(to be replaced with a custom page that is similar to the list files table)
* add own page for global search
untested - and route needs cleanup (if possible)
* fix File getRows
* remove "path" from SearchFiles (for now)
* fix caching for searched files
* add title and breadcrumbs to global search page
* make cpu & memory charts on console page working
* fix phpstan
* add missing import
* cleanup console views & widgets
* add overview stats to console
* don't be so lazy, console!
* make history working
* decode data to get array
* add missing On
* fix json_decode
* change polling to 1 sec
* hide "0" cpu/ memory
* add data to network chart
* Remove data labels
* fix data on network chart
* fix data on network chart (2nd try)
* WIP Network Stats
* Remove test
* Change MaxWidth
* run pint
* fix phpstan
* Fix storeStats cast
* make $data a string
this time for real
* update visible check for "admin" menu item
* remove account widget
* rebrand "Dashboard" to "Server List"
WIP - doesn't look good but is somewhat working
* fix canAccessPanel
* separate server list into own panel
* change path to avoid conflicts with old client area (and remove sidebar width)
* display correct icon and color on server list entries
* show total memory if server is offline
* replace custom server list page with ListRecords page
* fix tests
* fix namespace
* remove "open" button and make whole column clickable
* Update EditProfile
* run pint
* fix access to server list
* add new login page to panels
* fix next_run_at for new schedules
* use new DateTimeColumn
* add own column for file bytes
* return to server list when clicking title
* fix console loading
* handle server with "conflict state"
* add banner if server is in "conflict state"
* fix phpstan
* update docker image select
* fix permission checks on Settings & Startup pages
* fix query for activity log page
* fix activity log not being logged
* adjust ListActivities
* fix phpstan
* fix pint
* fix profile menu item link on server panel
* add ip tooltip to activity logs (and role permission)
* change backup icon
* update navigation sort
* general code cleanup
* more cleanup
* Disable Restart/Stop if server is offline
* Change rename notification
* Remove negation on abort_unless
* Add notification on save
* Single disabled closure & comment unused import
* Add required to Server Name & Nullable to description
* mutateFormDataBeforeSave doesn't work since we use forceFill
* Fix web socket connection not existing.
* Fix some subuser permissions
* add permission checks to resources
* do not allow self-deletion
* Update editing file permissions
* Fix of the previous fix
* add service for subuser updating
* Only allow save if they have file_update
* Remove unused import
* Update backup delete button
* Add Delete, remove bulks
* Update Database page
* Use Allocation Permissions
* add canAccess check to startup
* Add Permission checks to Settings page
* add service for subuser deletion
* Remove Kill permission
* Updates
* fix move files
* add redirects
* fix phpstan
* activity: remove properties from tans for now
* If alias, use that, else ip
---------
Co-authored-by: notCharles <charles@pelican.dev>
Co-authored-by: Boy132 <mail@boy132.de>
Co-authored-by: Senna <62171904+Poseidon281@users.noreply.github.com>
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
2024-11-30 22:13:45 -05:00
|
|
|
use Illuminate\Support\Collection;
|
2025-07-01 21:33:11 -04:00
|
|
|
use Illuminate\Support\Facades\App;
|
2024-03-31 02:09:23 -04:00
|
|
|
use Illuminate\Support\Str;
|
2018-01-01 15:11:44 -06:00
|
|
|
use Illuminate\Validation\Rules\In;
|
2025-01-16 14:53:50 -05:00
|
|
|
use ResourceBundle;
|
2024-09-21 12:27:41 +02:00
|
|
|
use Spatie\Permission\Traits\HasRoles;
|
2015-12-06 13:58:49 -05:00
|
|
|
|
2019-09-05 21:53:33 -07:00
|
|
|
/**
|
2024-03-12 22:39:16 -04:00
|
|
|
* App\Models\User.
|
2022-05-14 17:31:53 -04:00
|
|
|
*
|
2021-01-27 20:52:11 -08:00
|
|
|
* @property int $id
|
|
|
|
|
* @property string|null $external_id
|
|
|
|
|
* @property string $uuid
|
|
|
|
|
* @property string $username
|
|
|
|
|
* @property string $email
|
|
|
|
|
* @property string $password
|
2022-05-22 14:57:06 -04:00
|
|
|
* @property string|null $remember_token
|
2021-01-27 20:52:11 -08:00
|
|
|
* @property string $language
|
2024-06-29 23:42:46 +02:00
|
|
|
* @property string $timezone
|
2025-03-03 14:41:19 -05:00
|
|
|
* @property string[]|null $oauth
|
2025-09-08 13:12:33 -04:00
|
|
|
* @property string|null $mfa_app_secret
|
|
|
|
|
* @property string[]|null $mfa_app_recovery_codes
|
|
|
|
|
* @property bool $mfa_email_enabled
|
|
|
|
|
* @property Carbon|null $created_at
|
|
|
|
|
* @property Carbon|null $updated_at
|
|
|
|
|
* @property \Illuminate\Database\Eloquent\Collection|ApiKey[] $apiKeys
|
2022-05-14 17:31:53 -04:00
|
|
|
* @property int|null $api_keys_count
|
2025-09-08 13:12:33 -04:00
|
|
|
* @property DatabaseNotificationCollection|DatabaseNotification[] $notifications
|
2022-05-14 17:31:53 -04:00
|
|
|
* @property int|null $notifications_count
|
2025-09-08 13:12:33 -04:00
|
|
|
* @property \Illuminate\Database\Eloquent\Collection|Server[] $servers
|
2022-05-14 17:31:53 -04:00
|
|
|
* @property int|null $servers_count
|
2025-09-08 13:12:33 -04:00
|
|
|
* @property \Illuminate\Database\Eloquent\Collection|UserSSHKey[] $sshKeys
|
2022-05-14 17:31:53 -04:00
|
|
|
* @property int|null $ssh_keys_count
|
2025-09-08 13:12:33 -04:00
|
|
|
* @property \Illuminate\Database\Eloquent\Collection|ApiKey[] $tokens
|
2022-05-22 14:57:06 -04:00
|
|
|
* @property int|null $tokens_count
|
2025-09-08 13:12:33 -04:00
|
|
|
* @property \Illuminate\Database\Eloquent\Collection|Role[] $roles
|
2025-03-03 14:41:19 -05:00
|
|
|
* @property int|null $roles_count
|
2025-09-08 13:12:33 -04:00
|
|
|
* @property string|array<string, mixed>|null $customization
|
2022-05-14 17:31:53 -04:00
|
|
|
*
|
2025-09-08 13:12:33 -04:00
|
|
|
* @method static UserFactory factory(...$parameters)
|
2022-05-14 17:31:53 -04:00
|
|
|
* @method static Builder|User newModelQuery()
|
|
|
|
|
* @method static Builder|User newQuery()
|
|
|
|
|
* @method static Builder|User query()
|
|
|
|
|
* @method static Builder|User whereCreatedAt($value)
|
|
|
|
|
* @method static Builder|User whereEmail($value)
|
|
|
|
|
* @method static Builder|User whereExternalId($value)
|
|
|
|
|
* @method static Builder|User whereId($value)
|
|
|
|
|
* @method static Builder|User whereLanguage($value)
|
2024-06-29 23:42:46 +02:00
|
|
|
* @method static Builder|User whereTimezone($value)
|
2022-05-14 17:31:53 -04:00
|
|
|
* @method static Builder|User wherePassword($value)
|
|
|
|
|
* @method static Builder|User whereRememberToken($value)
|
|
|
|
|
* @method static Builder|User whereUpdatedAt($value)
|
|
|
|
|
* @method static Builder|User whereUsername($value)
|
|
|
|
|
* @method static Builder|User whereUuid($value)
|
2019-09-05 21:53:33 -07:00
|
|
|
*/
|
2025-09-08 13:12:33 -04:00
|
|
|
class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract, FilamentUser, HasAppAuthentication, HasAppAuthenticationRecovery, HasAvatar, HasEmailAuthentication, HasName, HasTenants, Validatable
|
2015-12-06 13:58:49 -05:00
|
|
|
{
|
2020-04-03 23:22:35 -07:00
|
|
|
use Authenticatable;
|
2025-01-30 16:39:00 -05:00
|
|
|
use Authorizable { can as protected canned; }
|
2020-04-03 23:22:35 -07:00
|
|
|
use CanResetPassword;
|
2022-05-22 19:03:51 -04:00
|
|
|
use HasAccessTokens;
|
2025-01-30 16:39:00 -05:00
|
|
|
use HasFactory;
|
2024-09-21 12:27:41 +02:00
|
|
|
use HasRoles;
|
2025-01-30 16:39:00 -05:00
|
|
|
use HasValidation { getRules as getValidationRules; }
|
2020-04-03 23:22:35 -07:00
|
|
|
use Notifiable;
|
2015-12-06 13:58:49 -05:00
|
|
|
|
2021-01-23 12:33:34 -08:00
|
|
|
public const USER_LEVEL_USER = 0;
|
2024-10-19 18:29:44 -04:00
|
|
|
|
2021-01-23 12:33:34 -08:00
|
|
|
public const USER_LEVEL_ADMIN = 1;
|
2017-10-26 23:49:54 -05:00
|
|
|
|
2018-01-25 21:26:06 -06:00
|
|
|
/**
|
|
|
|
|
* The resource name for this model when it is transformed into an
|
2024-11-06 09:09:10 +01:00
|
|
|
* API representation using fractal. Also used as name for api key permissions.
|
2018-01-25 21:26:06 -06:00
|
|
|
*/
|
2021-01-23 12:33:34 -08:00
|
|
|
public const RESOURCE_NAME = 'user';
|
2018-01-25 21:26:06 -06:00
|
|
|
|
2015-12-06 13:58:49 -05:00
|
|
|
/**
|
2017-01-12 15:40:24 -05:00
|
|
|
* A list of mass-assignable variables.
|
2015-12-06 13:58:49 -05:00
|
|
|
*/
|
2017-09-24 21:12:30 -05:00
|
|
|
protected $fillable = [
|
2018-02-24 14:47:53 -06:00
|
|
|
'external_id',
|
2017-09-24 21:12:30 -05:00
|
|
|
'username',
|
|
|
|
|
'email',
|
|
|
|
|
'password',
|
|
|
|
|
'language',
|
2024-06-25 20:17:08 -04:00
|
|
|
'timezone',
|
2025-09-08 13:12:33 -04:00
|
|
|
'mfa_app_secret',
|
|
|
|
|
'mfa_app_recovery_codes',
|
|
|
|
|
'mfa_email_enabled',
|
2024-06-13 21:06:31 +02:00
|
|
|
'oauth',
|
2025-04-04 12:08:43 -04:00
|
|
|
'customization',
|
2017-09-24 21:12:30 -05:00
|
|
|
];
|
2015-12-06 13:58:49 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The attributes excluded from the model's JSON form.
|
|
|
|
|
*/
|
2025-09-08 13:12:33 -04:00
|
|
|
protected $hidden = ['password', 'remember_token', 'mfa_app_secret', 'mfa_app_recovery_codes', 'oauth'];
|
2015-12-06 13:58:49 -05:00
|
|
|
|
2017-06-24 19:49:09 -05:00
|
|
|
/**
|
|
|
|
|
* Default values for specific fields in the database.
|
|
|
|
|
*/
|
|
|
|
|
protected $attributes = [
|
2018-02-25 16:08:01 -06:00
|
|
|
'external_id' => null,
|
2017-06-24 19:49:09 -05:00
|
|
|
'language' => 'en',
|
2024-06-29 23:42:46 +02:00
|
|
|
'timezone' => 'UTC',
|
2025-09-08 13:12:33 -04:00
|
|
|
'mfa_app_secret' => null,
|
|
|
|
|
'mfa_app_recovery_codes' => null,
|
|
|
|
|
'mfa_email_enabled' => false,
|
2024-06-13 21:06:31 +02:00
|
|
|
'oauth' => '[]',
|
2025-04-04 12:08:43 -04:00
|
|
|
'customization' => null,
|
2017-06-24 19:49:09 -05:00
|
|
|
];
|
|
|
|
|
|
2025-03-08 19:56:06 -05:00
|
|
|
/** @var array<array-key, string[]> */
|
2022-10-14 10:59:20 -06:00
|
|
|
public static array $validationRules = [
|
2025-03-08 19:56:06 -05:00
|
|
|
'uuid' => ['nullable', 'string', 'size:36', 'unique:users,uuid'],
|
|
|
|
|
'email' => ['required', 'email', 'between:1,255', 'unique:users,email'],
|
|
|
|
|
'external_id' => ['sometimes', 'nullable', 'string', 'max:255', 'unique:users,external_id'],
|
|
|
|
|
'username' => ['required', 'between:1,255', 'unique:users,username'],
|
|
|
|
|
'password' => ['sometimes', 'nullable', 'string'],
|
|
|
|
|
'language' => ['string'],
|
|
|
|
|
'timezone' => ['string'],
|
2025-09-08 13:12:33 -04:00
|
|
|
'mfa_app_secret' => ['nullable', 'string'],
|
|
|
|
|
'mfa_app_recovery_codes' => ['nullable', 'array'],
|
|
|
|
|
'mfa_app_recovery_codes.*' => ['string'],
|
|
|
|
|
'mfa_email_enabled' => ['boolean'],
|
2025-03-08 19:56:06 -05:00
|
|
|
'oauth' => ['array', 'nullable'],
|
2025-04-04 12:08:43 -04:00
|
|
|
'customization' => ['array', 'nullable'],
|
|
|
|
|
'customization.console_rows' => ['integer', 'min:1'],
|
|
|
|
|
'customization.console_font' => ['string'],
|
|
|
|
|
'customization.console_font_size' => ['integer', 'min:1'],
|
2025-09-08 13:12:33 -04:00
|
|
|
'customization.console_graph_period' => ['integer', 'min:1'],
|
|
|
|
|
'customization.top_navigation' => ['boolean'],
|
|
|
|
|
'customization.dashboard_layout' => ['string', 'in:grid,table'],
|
2017-06-24 19:49:09 -05:00
|
|
|
];
|
2017-04-01 13:14:49 -04:00
|
|
|
|
2024-03-19 21:08:49 -04:00
|
|
|
protected function casts(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
2025-09-08 13:12:33 -04:00
|
|
|
'mfa_app_secret' => 'encrypted',
|
|
|
|
|
'mfa_app_recovery_codes' => 'encrypted:array',
|
2024-06-13 21:06:31 +02:00
|
|
|
'oauth' => 'array',
|
2025-04-04 12:08:43 -04:00
|
|
|
'customization' => 'array',
|
2024-03-19 21:08:49 -04:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-18 21:23:13 -04:00
|
|
|
protected static function booted(): void
|
|
|
|
|
{
|
2024-03-31 02:09:23 -04:00
|
|
|
static::creating(function (self $user) {
|
2025-01-16 14:53:50 -05:00
|
|
|
$user->uuid ??= Str::uuid()->toString();
|
|
|
|
|
$user->timezone ??= config('app.timezone');
|
2024-11-15 20:41:33 +01:00
|
|
|
|
2024-03-31 02:09:23 -04:00
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
|
2025-03-30 14:44:03 -04:00
|
|
|
static::saving(function (self $user) {
|
|
|
|
|
$user->email = mb_strtolower($user->email);
|
|
|
|
|
});
|
|
|
|
|
|
2024-03-18 21:23:13 -04:00
|
|
|
static::deleting(function (self $user) {
|
2025-02-11 22:16:48 +01:00
|
|
|
throw_if($user->servers()->count() > 0, new DisplayException(trans('exceptions.users.has_servers')));
|
2024-03-18 21:23:13 -04:00
|
|
|
|
2025-02-11 22:16:48 +01:00
|
|
|
throw_if(request()->user()?->id === $user->id, new DisplayException(trans('exceptions.users.is_self')));
|
2024-03-18 21:23:13 -04:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-01 15:11:44 -06:00
|
|
|
/**
|
|
|
|
|
* Implement language verification by overriding Eloquence's gather
|
|
|
|
|
* rules function.
|
|
|
|
|
*/
|
2022-10-14 10:59:20 -06:00
|
|
|
public static function getRules(): array
|
2018-01-01 15:11:44 -06:00
|
|
|
{
|
2025-01-30 16:39:00 -05:00
|
|
|
$rules = self::getValidationRules();
|
2019-09-04 22:26:28 -07:00
|
|
|
|
2025-01-16 14:53:50 -05:00
|
|
|
$rules['language'][] = new In(array_values(array_filter(ResourceBundle::getLocales(''), fn ($lang) => preg_match('/^[a-z]{2}$/', $lang))));
|
|
|
|
|
$rules['timezone'][] = new In(DateTimeZone::listIdentifiers());
|
2018-01-01 15:11:44 -06:00
|
|
|
|
|
|
|
|
return $rules;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-03 14:41:19 -05:00
|
|
|
public function username(): Attribute
|
2017-06-10 22:28:44 -05:00
|
|
|
{
|
2025-03-03 14:41:19 -05:00
|
|
|
return Attribute::make(
|
2025-09-22 12:58:54 +02:00
|
|
|
set: fn (string $value) => str($value)->lower()->trim()->toString(),
|
2025-03-03 14:41:19 -05:00
|
|
|
);
|
2017-06-10 22:28:44 -05:00
|
|
|
}
|
|
|
|
|
|
2025-03-03 14:41:19 -05:00
|
|
|
public function email(): Attribute
|
2024-11-15 20:39:06 +01:00
|
|
|
{
|
2025-03-03 14:41:19 -05:00
|
|
|
return Attribute::make(
|
2025-09-22 12:58:54 +02:00
|
|
|
set: fn (string $value) => str($value)->lower()->trim()->toString(),
|
2025-03-03 14:41:19 -05:00
|
|
|
);
|
2024-11-15 20:39:06 +01:00
|
|
|
}
|
|
|
|
|
|
2017-02-09 17:43:54 -05:00
|
|
|
/**
|
|
|
|
|
* Returns all servers that a user owns.
|
2025-01-16 14:53:50 -05:00
|
|
|
*
|
|
|
|
|
* @return HasMany<Server, $this>
|
2017-02-09 17:43:54 -05:00
|
|
|
*/
|
2022-10-14 10:59:20 -06:00
|
|
|
public function servers(): HasMany
|
2017-02-09 17:43:54 -05:00
|
|
|
{
|
|
|
|
|
return $this->hasMany(Server::class, 'owner_id');
|
|
|
|
|
}
|
2017-04-13 23:49:47 -04:00
|
|
|
|
2022-10-14 10:59:20 -06:00
|
|
|
public function apiKeys(): HasMany
|
2020-03-22 18:15:38 -07:00
|
|
|
{
|
|
|
|
|
return $this->hasMany(ApiKey::class)
|
|
|
|
|
->where('key_type', ApiKey::TYPE_ACCOUNT);
|
|
|
|
|
}
|
2020-07-02 21:55:25 -07:00
|
|
|
|
2022-05-14 17:31:53 -04:00
|
|
|
public function sshKeys(): HasMany
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(UserSSHKey::class);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-29 16:19:04 -04:00
|
|
|
/**
|
2022-10-14 10:59:20 -06:00
|
|
|
* Returns all the activity logs where this user is the subject — not to
|
2022-05-29 16:19:04 -04:00
|
|
|
* be confused by activity logs where this user is the _actor_.
|
|
|
|
|
*/
|
|
|
|
|
public function activity(): MorphToMany
|
|
|
|
|
{
|
|
|
|
|
return $this->morphToMany(ActivityLog::class, 'subject', 'activity_log_subjects');
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-06 21:25:00 -07:00
|
|
|
/**
|
2025-01-17 23:04:22 +01:00
|
|
|
* Returns all the servers that a user can access.
|
|
|
|
|
* Either because they are an admin or because they are the owner/ a subuser of the server.
|
2020-07-06 21:25:00 -07:00
|
|
|
*/
|
2022-10-14 10:59:20 -06:00
|
|
|
public function accessibleServers(): Builder
|
2025-01-17 23:04:22 +01:00
|
|
|
{
|
2025-05-27 19:30:30 +02:00
|
|
|
if ($this->canned('viewAny', Server::class)) {
|
|
|
|
|
return Server::select('servers.*')
|
|
|
|
|
->leftJoin('subusers', 'subusers.server_id', '=', 'servers.id')
|
|
|
|
|
->where(function (Builder $builder) {
|
|
|
|
|
$builder->where('servers.owner_id', $this->id)->orWhere('subusers.user_id', $this->id)->orWhereIn('servers.node_id', $this->accessibleNodes()->pluck('id'));
|
|
|
|
|
})
|
|
|
|
|
->distinct('servers.id');
|
2025-01-17 23:04:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->directAccessibleServers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns all the servers that a user can access "directly".
|
|
|
|
|
* This means either because they are the owner or a subuser of the server.
|
|
|
|
|
*/
|
|
|
|
|
public function directAccessibleServers(): Builder
|
2020-07-06 21:25:00 -07:00
|
|
|
{
|
2025-05-27 19:30:30 +02:00
|
|
|
return Server::select('servers.*')
|
2020-07-06 21:25:00 -07:00
|
|
|
->leftJoin('subusers', 'subusers.server_id', '=', 'servers.id')
|
|
|
|
|
->where(function (Builder $builder) {
|
|
|
|
|
$builder->where('servers.owner_id', $this->id)->orWhere('subusers.user_id', $this->id);
|
2025-11-05 16:19:03 +01:00
|
|
|
})
|
|
|
|
|
->distinct('servers.id');
|
2020-07-06 21:25:00 -07:00
|
|
|
}
|
2024-03-16 18:53:53 -04:00
|
|
|
|
2025-05-05 12:58:55 +02:00
|
|
|
public function accessibleNodes(): Builder
|
|
|
|
|
{
|
|
|
|
|
// Root admins can access all nodes
|
|
|
|
|
if ($this->isRootAdmin()) {
|
|
|
|
|
return Node::query();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if there are no restrictions from any role
|
|
|
|
|
$roleIds = $this->roles()->pluck('id');
|
|
|
|
|
if (!NodeRole::whereIn('role_id', $roleIds)->exists()) {
|
|
|
|
|
return Node::query();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Node::whereHas('roles', fn (Builder $builder) => $builder->whereIn('roles.id', $roleIds));
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-24 14:42:45 -04:00
|
|
|
public function subusers(): HasMany
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Subuser::class);
|
|
|
|
|
}
|
|
|
|
|
|
feat: Client UI translate to Filament (from React) (#416)
* Add new panel
* Add some basic resource pages
* Wip
* Wip terminal
* Wip
* Add new panel
* Add some basic resource pages
* Wip
* [Sub-Users] Add Invite
TODO: The logic with permissions
* [Sub-Users] Fix Creation
* [Cron] Add basics
* Add basic auth and messages
* Add basic buttons
* WIP on issue/353
* WIP on issue/353
* Add Database page
* Update Database Page
* Start of Backup Page
* Composer Update
* Changes
* Send input
* Remove this includes
* Better offline handling
* Consolidate top nav config
* Update Backups Page
* Update Backups
* Change name
* Add Assign All, Layout Fixes.
* conflict
* update schedule pages
* fix phpstan
* update pint.json
* add cron presets to schedule
* fix tests
* fix task creation
* schedules: disable task creation if limit is reached & disable backup action if backup limit is 0
* update activity pages
* update resources
* Update Edit User
TODO: actually save permissions when they're changed.
TODO: Figure out why Control does not update it's state... but the rest do...
* .... Sure it works.
TODO: Update permissions when you save editing a sub user.
* user: update canAccessPanel & canAccessTenant
* add helper to convert bytes into readable format
* very basic file explorer
* files: fix some stuff & remove dummy data
* files: better error handling
* files: basic file editor
* files: add some actions
* File manager updates
* files: fix paths
* Revery Composer Upgrade, Fixes SQLite
* fix: Pint (#517)
feat: MenuItems to and from admin
* Update File Editing
Updated File Editing to its own page,
Added Permission checks for file manager.
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
* add enum for editor langs
* files: add upload & pull actions
* fix build
* files: handle images
* Update to Filament v3.2.98
* files: add remaining actions
* use `authorize` instead of `hidden`
* fix canAccessTenant
* update date columns
* files: testing & fixes
* Fix File Names
Co-authored-by: lancepioch <git@lance.sh>
* Combine Pull/Upload
* Fix BulkDelete
* Uncontained tabs
* Hide Lang Selection, Move Actions
* Update Monaco, more custom
* Add livewire config
livewire limits uploads to 12MB... who knows why...
Fixed uploading a single files failing
* files: fix record url
* basic setup for settings & startup page
* make abstract class for simple app pages
* Basic Startup Page
* Update nav sort
* small cleanup
* startup: fix shouldHideComponent & getSelectOptionsFromRules
* startup: fix non editable fields & set default value
* startup: add todo for save button
* Save Variables after update & off click
Variables update when the user clicks off the input.
* Notifications are cool
* Add rule validation
* Sort variables by sortid
* pint
* Settings Page + Startup Changes
* settings: cleanup
* refactor: use server model for ServerFormPage (formerly known as SimplePage)
* Use Repeater for variables
* Add Network, Remove breadcrumbs
* Add paginated to file explorer
* Fix updating variables
* Add link to go to new client area
* fix after merge
* Add graphs to console page
Graphs still need to get the data from the web socket.
* fix pint & phpstan
* fix authorizeAccess for EditFiles and Startup page
* Fix rules on startup page
* Update console size
* Fix node name
* add "global search" to files list
requires https://github.com/pelican-dev/wings/pull/44
* remove debug dummy data
* update view action on ListServers
* enable SPA mode for app panel
* remove colors from app panel
they are defined globally in AppServiceProvider
* update global search ui a bit
(to be replaced with a custom page that is similar to the list files table)
* add own page for global search
untested - and route needs cleanup (if possible)
* fix File getRows
* remove "path" from SearchFiles (for now)
* fix caching for searched files
* add title and breadcrumbs to global search page
* make cpu & memory charts on console page working
* fix phpstan
* add missing import
* cleanup console views & widgets
* add overview stats to console
* don't be so lazy, console!
* make history working
* decode data to get array
* add missing On
* fix json_decode
* change polling to 1 sec
* hide "0" cpu/ memory
* add data to network chart
* Remove data labels
* fix data on network chart
* fix data on network chart (2nd try)
* WIP Network Stats
* Remove test
* Change MaxWidth
* run pint
* fix phpstan
* Fix storeStats cast
* make $data a string
this time for real
* update visible check for "admin" menu item
* remove account widget
* rebrand "Dashboard" to "Server List"
WIP - doesn't look good but is somewhat working
* fix canAccessPanel
* separate server list into own panel
* change path to avoid conflicts with old client area (and remove sidebar width)
* display correct icon and color on server list entries
* show total memory if server is offline
* replace custom server list page with ListRecords page
* fix tests
* fix namespace
* remove "open" button and make whole column clickable
* Update EditProfile
* run pint
* fix access to server list
* add new login page to panels
* fix next_run_at for new schedules
* use new DateTimeColumn
* add own column for file bytes
* return to server list when clicking title
* fix console loading
* handle server with "conflict state"
* add banner if server is in "conflict state"
* fix phpstan
* update docker image select
* fix permission checks on Settings & Startup pages
* fix query for activity log page
* fix activity log not being logged
* adjust ListActivities
* fix phpstan
* fix pint
* fix profile menu item link on server panel
* add ip tooltip to activity logs (and role permission)
* change backup icon
* update navigation sort
* general code cleanup
* more cleanup
* Disable Restart/Stop if server is offline
* Change rename notification
* Remove negation on abort_unless
* Add notification on save
* Single disabled closure & comment unused import
* Add required to Server Name & Nullable to description
* mutateFormDataBeforeSave doesn't work since we use forceFill
* Fix web socket connection not existing.
* Fix some subuser permissions
* add permission checks to resources
* do not allow self-deletion
* Update editing file permissions
* Fix of the previous fix
* add service for subuser updating
* Only allow save if they have file_update
* Remove unused import
* Update backup delete button
* Add Delete, remove bulks
* Update Database page
* Use Allocation Permissions
* add canAccess check to startup
* Add Permission checks to Settings page
* add service for subuser deletion
* Remove Kill permission
* Updates
* fix move files
* add redirects
* fix phpstan
* activity: remove properties from tans for now
* If alias, use that, else ip
---------
Co-authored-by: notCharles <charles@pelican.dev>
Co-authored-by: Boy132 <mail@boy132.de>
Co-authored-by: Senna <62171904+Poseidon281@users.noreply.github.com>
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
2024-11-30 22:13:45 -05:00
|
|
|
public function subServers(): BelongsToMany
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(Server::class, 'subusers');
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-08 13:12:33 -04:00
|
|
|
/** @return ($key is null ? array<string, string|int|bool> : string|int|bool) */
|
|
|
|
|
public function getCustomization(?CustomizationKey $key = null): array|string|int|bool|null
|
|
|
|
|
{
|
|
|
|
|
$customization = (is_string($this->customization) ? json_decode($this->customization, true) : $this->customization) ?? [];
|
|
|
|
|
$customization = array_merge(CustomizationKey::getDefaultCustomization(), $customization);
|
|
|
|
|
|
|
|
|
|
return !$key ? $customization : $customization[$key->value];
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-16 18:53:53 -04:00
|
|
|
protected function checkPermission(Server $server, string $permission = ''): bool
|
|
|
|
|
{
|
2025-05-27 19:30:30 +02:00
|
|
|
if ($this->canned('update', $server) || $server->owner_id === $this->id) {
|
2025-01-17 23:04:22 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the user only has "view" permissions allow viewing the console
|
2025-05-27 19:30:30 +02:00
|
|
|
if ($permission === Permission::ACTION_WEBSOCKET_CONNECT && $this->canned('view', $server)) {
|
2024-03-16 18:53:53 -04:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$subuser = $server->subusers->where('user_id', $this->id)->first();
|
|
|
|
|
if (!$subuser || empty($permission)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$check = in_array($permission, $subuser->permissions);
|
|
|
|
|
|
|
|
|
|
return $check;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Laravel's policies strictly check for the existence of a real method,
|
|
|
|
|
* this checks if the ability is one of our permissions and then checks if the user can do it or not
|
|
|
|
|
* Otherwise it calls the Authorizable trait's parent method
|
2025-03-03 14:41:19 -05:00
|
|
|
*
|
2025-09-08 13:12:33 -04:00
|
|
|
* @param iterable<string|BackedEnum>|BackedEnum|string $abilities
|
2025-03-03 14:41:19 -05:00
|
|
|
* @param array<mixed>|mixed $arguments
|
2024-03-16 18:53:53 -04:00
|
|
|
*/
|
|
|
|
|
public function can($abilities, mixed $arguments = []): bool
|
|
|
|
|
{
|
|
|
|
|
if (is_string($abilities) && str_contains($abilities, '.')) {
|
|
|
|
|
[$permission, $key] = str($abilities)->explode('.', 2);
|
|
|
|
|
|
|
|
|
|
if (isset(Permission::permissions()[$permission]['keys'][$key])) {
|
|
|
|
|
if ($arguments instanceof Server) {
|
|
|
|
|
return $this->checkPermission($arguments, $abilities);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->canned($abilities, $arguments);
|
|
|
|
|
}
|
2024-03-23 20:17:48 -04:00
|
|
|
|
2024-04-06 23:58:10 -04:00
|
|
|
public function isLastRootAdmin(): bool
|
|
|
|
|
{
|
2024-09-21 12:27:41 +02:00
|
|
|
$rootAdmins = User::all()->filter(fn ($user) => $user->isRootAdmin());
|
2024-04-06 23:58:10 -04:00
|
|
|
|
2024-04-13 16:30:20 +03:00
|
|
|
return once(fn () => $rootAdmins->count() === 1 && $rootAdmins->first()->is($this));
|
2024-04-06 23:58:10 -04:00
|
|
|
}
|
|
|
|
|
|
2024-09-21 12:27:41 +02:00
|
|
|
public function isRootAdmin(): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->hasRole(Role::ROOT_ADMIN);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-17 23:04:22 +01:00
|
|
|
public function isAdmin(): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->isRootAdmin() || ($this->roles()->count() >= 1 && $this->getAllPermissions()->count() >= 1);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-23 20:17:48 -04:00
|
|
|
public function canAccessPanel(Panel $panel): bool
|
|
|
|
|
{
|
2024-09-21 12:27:41 +02:00
|
|
|
if ($this->isRootAdmin()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
feat: Client UI translate to Filament (from React) (#416)
* Add new panel
* Add some basic resource pages
* Wip
* Wip terminal
* Wip
* Add new panel
* Add some basic resource pages
* Wip
* [Sub-Users] Add Invite
TODO: The logic with permissions
* [Sub-Users] Fix Creation
* [Cron] Add basics
* Add basic auth and messages
* Add basic buttons
* WIP on issue/353
* WIP on issue/353
* Add Database page
* Update Database Page
* Start of Backup Page
* Composer Update
* Changes
* Send input
* Remove this includes
* Better offline handling
* Consolidate top nav config
* Update Backups Page
* Update Backups
* Change name
* Add Assign All, Layout Fixes.
* conflict
* update schedule pages
* fix phpstan
* update pint.json
* add cron presets to schedule
* fix tests
* fix task creation
* schedules: disable task creation if limit is reached & disable backup action if backup limit is 0
* update activity pages
* update resources
* Update Edit User
TODO: actually save permissions when they're changed.
TODO: Figure out why Control does not update it's state... but the rest do...
* .... Sure it works.
TODO: Update permissions when you save editing a sub user.
* user: update canAccessPanel & canAccessTenant
* add helper to convert bytes into readable format
* very basic file explorer
* files: fix some stuff & remove dummy data
* files: better error handling
* files: basic file editor
* files: add some actions
* File manager updates
* files: fix paths
* Revery Composer Upgrade, Fixes SQLite
* fix: Pint (#517)
feat: MenuItems to and from admin
* Update File Editing
Updated File Editing to its own page,
Added Permission checks for file manager.
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
* add enum for editor langs
* files: add upload & pull actions
* fix build
* files: handle images
* Update to Filament v3.2.98
* files: add remaining actions
* use `authorize` instead of `hidden`
* fix canAccessTenant
* update date columns
* files: testing & fixes
* Fix File Names
Co-authored-by: lancepioch <git@lance.sh>
* Combine Pull/Upload
* Fix BulkDelete
* Uncontained tabs
* Hide Lang Selection, Move Actions
* Update Monaco, more custom
* Add livewire config
livewire limits uploads to 12MB... who knows why...
Fixed uploading a single files failing
* files: fix record url
* basic setup for settings & startup page
* make abstract class for simple app pages
* Basic Startup Page
* Update nav sort
* small cleanup
* startup: fix shouldHideComponent & getSelectOptionsFromRules
* startup: fix non editable fields & set default value
* startup: add todo for save button
* Save Variables after update & off click
Variables update when the user clicks off the input.
* Notifications are cool
* Add rule validation
* Sort variables by sortid
* pint
* Settings Page + Startup Changes
* settings: cleanup
* refactor: use server model for ServerFormPage (formerly known as SimplePage)
* Use Repeater for variables
* Add Network, Remove breadcrumbs
* Add paginated to file explorer
* Fix updating variables
* Add link to go to new client area
* fix after merge
* Add graphs to console page
Graphs still need to get the data from the web socket.
* fix pint & phpstan
* fix authorizeAccess for EditFiles and Startup page
* Fix rules on startup page
* Update console size
* Fix node name
* add "global search" to files list
requires https://github.com/pelican-dev/wings/pull/44
* remove debug dummy data
* update view action on ListServers
* enable SPA mode for app panel
* remove colors from app panel
they are defined globally in AppServiceProvider
* update global search ui a bit
(to be replaced with a custom page that is similar to the list files table)
* add own page for global search
untested - and route needs cleanup (if possible)
* fix File getRows
* remove "path" from SearchFiles (for now)
* fix caching for searched files
* add title and breadcrumbs to global search page
* make cpu & memory charts on console page working
* fix phpstan
* add missing import
* cleanup console views & widgets
* add overview stats to console
* don't be so lazy, console!
* make history working
* decode data to get array
* add missing On
* fix json_decode
* change polling to 1 sec
* hide "0" cpu/ memory
* add data to network chart
* Remove data labels
* fix data on network chart
* fix data on network chart (2nd try)
* WIP Network Stats
* Remove test
* Change MaxWidth
* run pint
* fix phpstan
* Fix storeStats cast
* make $data a string
this time for real
* update visible check for "admin" menu item
* remove account widget
* rebrand "Dashboard" to "Server List"
WIP - doesn't look good but is somewhat working
* fix canAccessPanel
* separate server list into own panel
* change path to avoid conflicts with old client area (and remove sidebar width)
* display correct icon and color on server list entries
* show total memory if server is offline
* replace custom server list page with ListRecords page
* fix tests
* fix namespace
* remove "open" button and make whole column clickable
* Update EditProfile
* run pint
* fix access to server list
* add new login page to panels
* fix next_run_at for new schedules
* use new DateTimeColumn
* add own column for file bytes
* return to server list when clicking title
* fix console loading
* handle server with "conflict state"
* add banner if server is in "conflict state"
* fix phpstan
* update docker image select
* fix permission checks on Settings & Startup pages
* fix query for activity log page
* fix activity log not being logged
* adjust ListActivities
* fix phpstan
* fix pint
* fix profile menu item link on server panel
* add ip tooltip to activity logs (and role permission)
* change backup icon
* update navigation sort
* general code cleanup
* more cleanup
* Disable Restart/Stop if server is offline
* Change rename notification
* Remove negation on abort_unless
* Add notification on save
* Single disabled closure & comment unused import
* Add required to Server Name & Nullable to description
* mutateFormDataBeforeSave doesn't work since we use forceFill
* Fix web socket connection not existing.
* Fix some subuser permissions
* add permission checks to resources
* do not allow self-deletion
* Update editing file permissions
* Fix of the previous fix
* add service for subuser updating
* Only allow save if they have file_update
* Remove unused import
* Update backup delete button
* Add Delete, remove bulks
* Update Database page
* Use Allocation Permissions
* add canAccess check to startup
* Add Permission checks to Settings page
* add service for subuser deletion
* Remove Kill permission
* Updates
* fix move files
* add redirects
* fix phpstan
* activity: remove properties from tans for now
* If alias, use that, else ip
---------
Co-authored-by: notCharles <charles@pelican.dev>
Co-authored-by: Boy132 <mail@boy132.de>
Co-authored-by: Senna <62171904+Poseidon281@users.noreply.github.com>
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
2024-11-30 22:13:45 -05:00
|
|
|
if ($panel->getId() === 'admin') {
|
2025-01-17 23:04:22 +01:00
|
|
|
return $this->isAdmin();
|
feat: Client UI translate to Filament (from React) (#416)
* Add new panel
* Add some basic resource pages
* Wip
* Wip terminal
* Wip
* Add new panel
* Add some basic resource pages
* Wip
* [Sub-Users] Add Invite
TODO: The logic with permissions
* [Sub-Users] Fix Creation
* [Cron] Add basics
* Add basic auth and messages
* Add basic buttons
* WIP on issue/353
* WIP on issue/353
* Add Database page
* Update Database Page
* Start of Backup Page
* Composer Update
* Changes
* Send input
* Remove this includes
* Better offline handling
* Consolidate top nav config
* Update Backups Page
* Update Backups
* Change name
* Add Assign All, Layout Fixes.
* conflict
* update schedule pages
* fix phpstan
* update pint.json
* add cron presets to schedule
* fix tests
* fix task creation
* schedules: disable task creation if limit is reached & disable backup action if backup limit is 0
* update activity pages
* update resources
* Update Edit User
TODO: actually save permissions when they're changed.
TODO: Figure out why Control does not update it's state... but the rest do...
* .... Sure it works.
TODO: Update permissions when you save editing a sub user.
* user: update canAccessPanel & canAccessTenant
* add helper to convert bytes into readable format
* very basic file explorer
* files: fix some stuff & remove dummy data
* files: better error handling
* files: basic file editor
* files: add some actions
* File manager updates
* files: fix paths
* Revery Composer Upgrade, Fixes SQLite
* fix: Pint (#517)
feat: MenuItems to and from admin
* Update File Editing
Updated File Editing to its own page,
Added Permission checks for file manager.
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
* add enum for editor langs
* files: add upload & pull actions
* fix build
* files: handle images
* Update to Filament v3.2.98
* files: add remaining actions
* use `authorize` instead of `hidden`
* fix canAccessTenant
* update date columns
* files: testing & fixes
* Fix File Names
Co-authored-by: lancepioch <git@lance.sh>
* Combine Pull/Upload
* Fix BulkDelete
* Uncontained tabs
* Hide Lang Selection, Move Actions
* Update Monaco, more custom
* Add livewire config
livewire limits uploads to 12MB... who knows why...
Fixed uploading a single files failing
* files: fix record url
* basic setup for settings & startup page
* make abstract class for simple app pages
* Basic Startup Page
* Update nav sort
* small cleanup
* startup: fix shouldHideComponent & getSelectOptionsFromRules
* startup: fix non editable fields & set default value
* startup: add todo for save button
* Save Variables after update & off click
Variables update when the user clicks off the input.
* Notifications are cool
* Add rule validation
* Sort variables by sortid
* pint
* Settings Page + Startup Changes
* settings: cleanup
* refactor: use server model for ServerFormPage (formerly known as SimplePage)
* Use Repeater for variables
* Add Network, Remove breadcrumbs
* Add paginated to file explorer
* Fix updating variables
* Add link to go to new client area
* fix after merge
* Add graphs to console page
Graphs still need to get the data from the web socket.
* fix pint & phpstan
* fix authorizeAccess for EditFiles and Startup page
* Fix rules on startup page
* Update console size
* Fix node name
* add "global search" to files list
requires https://github.com/pelican-dev/wings/pull/44
* remove debug dummy data
* update view action on ListServers
* enable SPA mode for app panel
* remove colors from app panel
they are defined globally in AppServiceProvider
* update global search ui a bit
(to be replaced with a custom page that is similar to the list files table)
* add own page for global search
untested - and route needs cleanup (if possible)
* fix File getRows
* remove "path" from SearchFiles (for now)
* fix caching for searched files
* add title and breadcrumbs to global search page
* make cpu & memory charts on console page working
* fix phpstan
* add missing import
* cleanup console views & widgets
* add overview stats to console
* don't be so lazy, console!
* make history working
* decode data to get array
* add missing On
* fix json_decode
* change polling to 1 sec
* hide "0" cpu/ memory
* add data to network chart
* Remove data labels
* fix data on network chart
* fix data on network chart (2nd try)
* WIP Network Stats
* Remove test
* Change MaxWidth
* run pint
* fix phpstan
* Fix storeStats cast
* make $data a string
this time for real
* update visible check for "admin" menu item
* remove account widget
* rebrand "Dashboard" to "Server List"
WIP - doesn't look good but is somewhat working
* fix canAccessPanel
* separate server list into own panel
* change path to avoid conflicts with old client area (and remove sidebar width)
* display correct icon and color on server list entries
* show total memory if server is offline
* replace custom server list page with ListRecords page
* fix tests
* fix namespace
* remove "open" button and make whole column clickable
* Update EditProfile
* run pint
* fix access to server list
* add new login page to panels
* fix next_run_at for new schedules
* use new DateTimeColumn
* add own column for file bytes
* return to server list when clicking title
* fix console loading
* handle server with "conflict state"
* add banner if server is in "conflict state"
* fix phpstan
* update docker image select
* fix permission checks on Settings & Startup pages
* fix query for activity log page
* fix activity log not being logged
* adjust ListActivities
* fix phpstan
* fix pint
* fix profile menu item link on server panel
* add ip tooltip to activity logs (and role permission)
* change backup icon
* update navigation sort
* general code cleanup
* more cleanup
* Disable Restart/Stop if server is offline
* Change rename notification
* Remove negation on abort_unless
* Add notification on save
* Single disabled closure & comment unused import
* Add required to Server Name & Nullable to description
* mutateFormDataBeforeSave doesn't work since we use forceFill
* Fix web socket connection not existing.
* Fix some subuser permissions
* add permission checks to resources
* do not allow self-deletion
* Update editing file permissions
* Fix of the previous fix
* add service for subuser updating
* Only allow save if they have file_update
* Remove unused import
* Update backup delete button
* Add Delete, remove bulks
* Update Database page
* Use Allocation Permissions
* add canAccess check to startup
* Add Permission checks to Settings page
* add service for subuser deletion
* Remove Kill permission
* Updates
* fix move files
* add redirects
* fix phpstan
* activity: remove properties from tans for now
* If alias, use that, else ip
---------
Co-authored-by: notCharles <charles@pelican.dev>
Co-authored-by: Boy132 <mail@boy132.de>
Co-authored-by: Senna <62171904+Poseidon281@users.noreply.github.com>
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
2024-11-30 22:13:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
2024-03-23 20:17:48 -04:00
|
|
|
}
|
2024-04-06 10:11:10 -04:00
|
|
|
|
|
|
|
|
public function getFilamentName(): string
|
|
|
|
|
{
|
2025-01-03 17:13:44 -05:00
|
|
|
return $this->username;
|
2024-04-06 10:11:10 -04:00
|
|
|
}
|
|
|
|
|
|
2025-04-23 16:02:52 +02:00
|
|
|
public function getFilamentAvatarUrl(): ?string
|
|
|
|
|
{
|
2025-07-01 21:33:11 -04:00
|
|
|
return App::call(fn (AvatarService $service) => $service->getAvatarUrl($this));
|
2025-04-23 16:02:52 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-05 12:58:55 +02:00
|
|
|
public function canTarget(Model $model): bool
|
2024-09-21 12:27:41 +02:00
|
|
|
{
|
2025-05-05 12:58:55 +02:00
|
|
|
// Root admins can target everyone and everything
|
2024-09-21 12:27:41 +02:00
|
|
|
if ($this->isRootAdmin()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-05 12:58:55 +02:00
|
|
|
// Make sure normal admins can't target root admins
|
|
|
|
|
if ($model instanceof User) {
|
|
|
|
|
return !$model->isRootAdmin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make sure the user can only target accessible nodes
|
|
|
|
|
if ($model instanceof Node) {
|
|
|
|
|
return $this->accessibleNodes()->where('id', $model->id)->exists();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
2024-09-21 12:27:41 +02:00
|
|
|
}
|
feat: Client UI translate to Filament (from React) (#416)
* Add new panel
* Add some basic resource pages
* Wip
* Wip terminal
* Wip
* Add new panel
* Add some basic resource pages
* Wip
* [Sub-Users] Add Invite
TODO: The logic with permissions
* [Sub-Users] Fix Creation
* [Cron] Add basics
* Add basic auth and messages
* Add basic buttons
* WIP on issue/353
* WIP on issue/353
* Add Database page
* Update Database Page
* Start of Backup Page
* Composer Update
* Changes
* Send input
* Remove this includes
* Better offline handling
* Consolidate top nav config
* Update Backups Page
* Update Backups
* Change name
* Add Assign All, Layout Fixes.
* conflict
* update schedule pages
* fix phpstan
* update pint.json
* add cron presets to schedule
* fix tests
* fix task creation
* schedules: disable task creation if limit is reached & disable backup action if backup limit is 0
* update activity pages
* update resources
* Update Edit User
TODO: actually save permissions when they're changed.
TODO: Figure out why Control does not update it's state... but the rest do...
* .... Sure it works.
TODO: Update permissions when you save editing a sub user.
* user: update canAccessPanel & canAccessTenant
* add helper to convert bytes into readable format
* very basic file explorer
* files: fix some stuff & remove dummy data
* files: better error handling
* files: basic file editor
* files: add some actions
* File manager updates
* files: fix paths
* Revery Composer Upgrade, Fixes SQLite
* fix: Pint (#517)
feat: MenuItems to and from admin
* Update File Editing
Updated File Editing to its own page,
Added Permission checks for file manager.
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
* add enum for editor langs
* files: add upload & pull actions
* fix build
* files: handle images
* Update to Filament v3.2.98
* files: add remaining actions
* use `authorize` instead of `hidden`
* fix canAccessTenant
* update date columns
* files: testing & fixes
* Fix File Names
Co-authored-by: lancepioch <git@lance.sh>
* Combine Pull/Upload
* Fix BulkDelete
* Uncontained tabs
* Hide Lang Selection, Move Actions
* Update Monaco, more custom
* Add livewire config
livewire limits uploads to 12MB... who knows why...
Fixed uploading a single files failing
* files: fix record url
* basic setup for settings & startup page
* make abstract class for simple app pages
* Basic Startup Page
* Update nav sort
* small cleanup
* startup: fix shouldHideComponent & getSelectOptionsFromRules
* startup: fix non editable fields & set default value
* startup: add todo for save button
* Save Variables after update & off click
Variables update when the user clicks off the input.
* Notifications are cool
* Add rule validation
* Sort variables by sortid
* pint
* Settings Page + Startup Changes
* settings: cleanup
* refactor: use server model for ServerFormPage (formerly known as SimplePage)
* Use Repeater for variables
* Add Network, Remove breadcrumbs
* Add paginated to file explorer
* Fix updating variables
* Add link to go to new client area
* fix after merge
* Add graphs to console page
Graphs still need to get the data from the web socket.
* fix pint & phpstan
* fix authorizeAccess for EditFiles and Startup page
* Fix rules on startup page
* Update console size
* Fix node name
* add "global search" to files list
requires https://github.com/pelican-dev/wings/pull/44
* remove debug dummy data
* update view action on ListServers
* enable SPA mode for app panel
* remove colors from app panel
they are defined globally in AppServiceProvider
* update global search ui a bit
(to be replaced with a custom page that is similar to the list files table)
* add own page for global search
untested - and route needs cleanup (if possible)
* fix File getRows
* remove "path" from SearchFiles (for now)
* fix caching for searched files
* add title and breadcrumbs to global search page
* make cpu & memory charts on console page working
* fix phpstan
* add missing import
* cleanup console views & widgets
* add overview stats to console
* don't be so lazy, console!
* make history working
* decode data to get array
* add missing On
* fix json_decode
* change polling to 1 sec
* hide "0" cpu/ memory
* add data to network chart
* Remove data labels
* fix data on network chart
* fix data on network chart (2nd try)
* WIP Network Stats
* Remove test
* Change MaxWidth
* run pint
* fix phpstan
* Fix storeStats cast
* make $data a string
this time for real
* update visible check for "admin" menu item
* remove account widget
* rebrand "Dashboard" to "Server List"
WIP - doesn't look good but is somewhat working
* fix canAccessPanel
* separate server list into own panel
* change path to avoid conflicts with old client area (and remove sidebar width)
* display correct icon and color on server list entries
* show total memory if server is offline
* replace custom server list page with ListRecords page
* fix tests
* fix namespace
* remove "open" button and make whole column clickable
* Update EditProfile
* run pint
* fix access to server list
* add new login page to panels
* fix next_run_at for new schedules
* use new DateTimeColumn
* add own column for file bytes
* return to server list when clicking title
* fix console loading
* handle server with "conflict state"
* add banner if server is in "conflict state"
* fix phpstan
* update docker image select
* fix permission checks on Settings & Startup pages
* fix query for activity log page
* fix activity log not being logged
* adjust ListActivities
* fix phpstan
* fix pint
* fix profile menu item link on server panel
* add ip tooltip to activity logs (and role permission)
* change backup icon
* update navigation sort
* general code cleanup
* more cleanup
* Disable Restart/Stop if server is offline
* Change rename notification
* Remove negation on abort_unless
* Add notification on save
* Single disabled closure & comment unused import
* Add required to Server Name & Nullable to description
* mutateFormDataBeforeSave doesn't work since we use forceFill
* Fix web socket connection not existing.
* Fix some subuser permissions
* add permission checks to resources
* do not allow self-deletion
* Update editing file permissions
* Fix of the previous fix
* add service for subuser updating
* Only allow save if they have file_update
* Remove unused import
* Update backup delete button
* Add Delete, remove bulks
* Update Database page
* Use Allocation Permissions
* add canAccess check to startup
* Add Permission checks to Settings page
* add service for subuser deletion
* Remove Kill permission
* Updates
* fix move files
* add redirects
* fix phpstan
* activity: remove properties from tans for now
* If alias, use that, else ip
---------
Co-authored-by: notCharles <charles@pelican.dev>
Co-authored-by: Boy132 <mail@boy132.de>
Co-authored-by: Senna <62171904+Poseidon281@users.noreply.github.com>
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
2024-11-30 22:13:45 -05:00
|
|
|
|
|
|
|
|
public function getTenants(Panel $panel): array|Collection
|
|
|
|
|
{
|
|
|
|
|
return $this->accessibleServers()->get();
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-30 16:39:00 -05:00
|
|
|
public function canAccessTenant(Model $tenant): bool
|
feat: Client UI translate to Filament (from React) (#416)
* Add new panel
* Add some basic resource pages
* Wip
* Wip terminal
* Wip
* Add new panel
* Add some basic resource pages
* Wip
* [Sub-Users] Add Invite
TODO: The logic with permissions
* [Sub-Users] Fix Creation
* [Cron] Add basics
* Add basic auth and messages
* Add basic buttons
* WIP on issue/353
* WIP on issue/353
* Add Database page
* Update Database Page
* Start of Backup Page
* Composer Update
* Changes
* Send input
* Remove this includes
* Better offline handling
* Consolidate top nav config
* Update Backups Page
* Update Backups
* Change name
* Add Assign All, Layout Fixes.
* conflict
* update schedule pages
* fix phpstan
* update pint.json
* add cron presets to schedule
* fix tests
* fix task creation
* schedules: disable task creation if limit is reached & disable backup action if backup limit is 0
* update activity pages
* update resources
* Update Edit User
TODO: actually save permissions when they're changed.
TODO: Figure out why Control does not update it's state... but the rest do...
* .... Sure it works.
TODO: Update permissions when you save editing a sub user.
* user: update canAccessPanel & canAccessTenant
* add helper to convert bytes into readable format
* very basic file explorer
* files: fix some stuff & remove dummy data
* files: better error handling
* files: basic file editor
* files: add some actions
* File manager updates
* files: fix paths
* Revery Composer Upgrade, Fixes SQLite
* fix: Pint (#517)
feat: MenuItems to and from admin
* Update File Editing
Updated File Editing to its own page,
Added Permission checks for file manager.
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
* add enum for editor langs
* files: add upload & pull actions
* fix build
* files: handle images
* Update to Filament v3.2.98
* files: add remaining actions
* use `authorize` instead of `hidden`
* fix canAccessTenant
* update date columns
* files: testing & fixes
* Fix File Names
Co-authored-by: lancepioch <git@lance.sh>
* Combine Pull/Upload
* Fix BulkDelete
* Uncontained tabs
* Hide Lang Selection, Move Actions
* Update Monaco, more custom
* Add livewire config
livewire limits uploads to 12MB... who knows why...
Fixed uploading a single files failing
* files: fix record url
* basic setup for settings & startup page
* make abstract class for simple app pages
* Basic Startup Page
* Update nav sort
* small cleanup
* startup: fix shouldHideComponent & getSelectOptionsFromRules
* startup: fix non editable fields & set default value
* startup: add todo for save button
* Save Variables after update & off click
Variables update when the user clicks off the input.
* Notifications are cool
* Add rule validation
* Sort variables by sortid
* pint
* Settings Page + Startup Changes
* settings: cleanup
* refactor: use server model for ServerFormPage (formerly known as SimplePage)
* Use Repeater for variables
* Add Network, Remove breadcrumbs
* Add paginated to file explorer
* Fix updating variables
* Add link to go to new client area
* fix after merge
* Add graphs to console page
Graphs still need to get the data from the web socket.
* fix pint & phpstan
* fix authorizeAccess for EditFiles and Startup page
* Fix rules on startup page
* Update console size
* Fix node name
* add "global search" to files list
requires https://github.com/pelican-dev/wings/pull/44
* remove debug dummy data
* update view action on ListServers
* enable SPA mode for app panel
* remove colors from app panel
they are defined globally in AppServiceProvider
* update global search ui a bit
(to be replaced with a custom page that is similar to the list files table)
* add own page for global search
untested - and route needs cleanup (if possible)
* fix File getRows
* remove "path" from SearchFiles (for now)
* fix caching for searched files
* add title and breadcrumbs to global search page
* make cpu & memory charts on console page working
* fix phpstan
* add missing import
* cleanup console views & widgets
* add overview stats to console
* don't be so lazy, console!
* make history working
* decode data to get array
* add missing On
* fix json_decode
* change polling to 1 sec
* hide "0" cpu/ memory
* add data to network chart
* Remove data labels
* fix data on network chart
* fix data on network chart (2nd try)
* WIP Network Stats
* Remove test
* Change MaxWidth
* run pint
* fix phpstan
* Fix storeStats cast
* make $data a string
this time for real
* update visible check for "admin" menu item
* remove account widget
* rebrand "Dashboard" to "Server List"
WIP - doesn't look good but is somewhat working
* fix canAccessPanel
* separate server list into own panel
* change path to avoid conflicts with old client area (and remove sidebar width)
* display correct icon and color on server list entries
* show total memory if server is offline
* replace custom server list page with ListRecords page
* fix tests
* fix namespace
* remove "open" button and make whole column clickable
* Update EditProfile
* run pint
* fix access to server list
* add new login page to panels
* fix next_run_at for new schedules
* use new DateTimeColumn
* add own column for file bytes
* return to server list when clicking title
* fix console loading
* handle server with "conflict state"
* add banner if server is in "conflict state"
* fix phpstan
* update docker image select
* fix permission checks on Settings & Startup pages
* fix query for activity log page
* fix activity log not being logged
* adjust ListActivities
* fix phpstan
* fix pint
* fix profile menu item link on server panel
* add ip tooltip to activity logs (and role permission)
* change backup icon
* update navigation sort
* general code cleanup
* more cleanup
* Disable Restart/Stop if server is offline
* Change rename notification
* Remove negation on abort_unless
* Add notification on save
* Single disabled closure & comment unused import
* Add required to Server Name & Nullable to description
* mutateFormDataBeforeSave doesn't work since we use forceFill
* Fix web socket connection not existing.
* Fix some subuser permissions
* add permission checks to resources
* do not allow self-deletion
* Update editing file permissions
* Fix of the previous fix
* add service for subuser updating
* Only allow save if they have file_update
* Remove unused import
* Update backup delete button
* Add Delete, remove bulks
* Update Database page
* Use Allocation Permissions
* add canAccess check to startup
* Add Permission checks to Settings page
* add service for subuser deletion
* Remove Kill permission
* Updates
* fix move files
* add redirects
* fix phpstan
* activity: remove properties from tans for now
* If alias, use that, else ip
---------
Co-authored-by: notCharles <charles@pelican.dev>
Co-authored-by: Boy132 <mail@boy132.de>
Co-authored-by: Senna <62171904+Poseidon281@users.noreply.github.com>
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
2024-11-30 22:13:45 -05:00
|
|
|
{
|
|
|
|
|
if ($tenant instanceof Server) {
|
2025-05-27 19:30:30 +02:00
|
|
|
if ($this->canned('view', $tenant) || $tenant->owner_id === $this->id) {
|
feat: Client UI translate to Filament (from React) (#416)
* Add new panel
* Add some basic resource pages
* Wip
* Wip terminal
* Wip
* Add new panel
* Add some basic resource pages
* Wip
* [Sub-Users] Add Invite
TODO: The logic with permissions
* [Sub-Users] Fix Creation
* [Cron] Add basics
* Add basic auth and messages
* Add basic buttons
* WIP on issue/353
* WIP on issue/353
* Add Database page
* Update Database Page
* Start of Backup Page
* Composer Update
* Changes
* Send input
* Remove this includes
* Better offline handling
* Consolidate top nav config
* Update Backups Page
* Update Backups
* Change name
* Add Assign All, Layout Fixes.
* conflict
* update schedule pages
* fix phpstan
* update pint.json
* add cron presets to schedule
* fix tests
* fix task creation
* schedules: disable task creation if limit is reached & disable backup action if backup limit is 0
* update activity pages
* update resources
* Update Edit User
TODO: actually save permissions when they're changed.
TODO: Figure out why Control does not update it's state... but the rest do...
* .... Sure it works.
TODO: Update permissions when you save editing a sub user.
* user: update canAccessPanel & canAccessTenant
* add helper to convert bytes into readable format
* very basic file explorer
* files: fix some stuff & remove dummy data
* files: better error handling
* files: basic file editor
* files: add some actions
* File manager updates
* files: fix paths
* Revery Composer Upgrade, Fixes SQLite
* fix: Pint (#517)
feat: MenuItems to and from admin
* Update File Editing
Updated File Editing to its own page,
Added Permission checks for file manager.
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
* add enum for editor langs
* files: add upload & pull actions
* fix build
* files: handle images
* Update to Filament v3.2.98
* files: add remaining actions
* use `authorize` instead of `hidden`
* fix canAccessTenant
* update date columns
* files: testing & fixes
* Fix File Names
Co-authored-by: lancepioch <git@lance.sh>
* Combine Pull/Upload
* Fix BulkDelete
* Uncontained tabs
* Hide Lang Selection, Move Actions
* Update Monaco, more custom
* Add livewire config
livewire limits uploads to 12MB... who knows why...
Fixed uploading a single files failing
* files: fix record url
* basic setup for settings & startup page
* make abstract class for simple app pages
* Basic Startup Page
* Update nav sort
* small cleanup
* startup: fix shouldHideComponent & getSelectOptionsFromRules
* startup: fix non editable fields & set default value
* startup: add todo for save button
* Save Variables after update & off click
Variables update when the user clicks off the input.
* Notifications are cool
* Add rule validation
* Sort variables by sortid
* pint
* Settings Page + Startup Changes
* settings: cleanup
* refactor: use server model for ServerFormPage (formerly known as SimplePage)
* Use Repeater for variables
* Add Network, Remove breadcrumbs
* Add paginated to file explorer
* Fix updating variables
* Add link to go to new client area
* fix after merge
* Add graphs to console page
Graphs still need to get the data from the web socket.
* fix pint & phpstan
* fix authorizeAccess for EditFiles and Startup page
* Fix rules on startup page
* Update console size
* Fix node name
* add "global search" to files list
requires https://github.com/pelican-dev/wings/pull/44
* remove debug dummy data
* update view action on ListServers
* enable SPA mode for app panel
* remove colors from app panel
they are defined globally in AppServiceProvider
* update global search ui a bit
(to be replaced with a custom page that is similar to the list files table)
* add own page for global search
untested - and route needs cleanup (if possible)
* fix File getRows
* remove "path" from SearchFiles (for now)
* fix caching for searched files
* add title and breadcrumbs to global search page
* make cpu & memory charts on console page working
* fix phpstan
* add missing import
* cleanup console views & widgets
* add overview stats to console
* don't be so lazy, console!
* make history working
* decode data to get array
* add missing On
* fix json_decode
* change polling to 1 sec
* hide "0" cpu/ memory
* add data to network chart
* Remove data labels
* fix data on network chart
* fix data on network chart (2nd try)
* WIP Network Stats
* Remove test
* Change MaxWidth
* run pint
* fix phpstan
* Fix storeStats cast
* make $data a string
this time for real
* update visible check for "admin" menu item
* remove account widget
* rebrand "Dashboard" to "Server List"
WIP - doesn't look good but is somewhat working
* fix canAccessPanel
* separate server list into own panel
* change path to avoid conflicts with old client area (and remove sidebar width)
* display correct icon and color on server list entries
* show total memory if server is offline
* replace custom server list page with ListRecords page
* fix tests
* fix namespace
* remove "open" button and make whole column clickable
* Update EditProfile
* run pint
* fix access to server list
* add new login page to panels
* fix next_run_at for new schedules
* use new DateTimeColumn
* add own column for file bytes
* return to server list when clicking title
* fix console loading
* handle server with "conflict state"
* add banner if server is in "conflict state"
* fix phpstan
* update docker image select
* fix permission checks on Settings & Startup pages
* fix query for activity log page
* fix activity log not being logged
* adjust ListActivities
* fix phpstan
* fix pint
* fix profile menu item link on server panel
* add ip tooltip to activity logs (and role permission)
* change backup icon
* update navigation sort
* general code cleanup
* more cleanup
* Disable Restart/Stop if server is offline
* Change rename notification
* Remove negation on abort_unless
* Add notification on save
* Single disabled closure & comment unused import
* Add required to Server Name & Nullable to description
* mutateFormDataBeforeSave doesn't work since we use forceFill
* Fix web socket connection not existing.
* Fix some subuser permissions
* add permission checks to resources
* do not allow self-deletion
* Update editing file permissions
* Fix of the previous fix
* add service for subuser updating
* Only allow save if they have file_update
* Remove unused import
* Update backup delete button
* Add Delete, remove bulks
* Update Database page
* Use Allocation Permissions
* add canAccess check to startup
* Add Permission checks to Settings page
* add service for subuser deletion
* Remove Kill permission
* Updates
* fix move files
* add redirects
* fix phpstan
* activity: remove properties from tans for now
* If alias, use that, else ip
---------
Co-authored-by: notCharles <charles@pelican.dev>
Co-authored-by: Boy132 <mail@boy132.de>
Co-authored-by: Senna <62171904+Poseidon281@users.noreply.github.com>
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
2024-11-30 22:13:45 -05:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$subuser = $tenant->subusers->where('user_id', $this->id)->first();
|
|
|
|
|
|
|
|
|
|
return $subuser !== null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2025-04-04 12:08:43 -04:00
|
|
|
|
2025-09-08 13:12:33 -04:00
|
|
|
public function getAppAuthenticationSecret(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->mfa_app_secret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function saveAppAuthenticationSecret(?string $secret): void
|
|
|
|
|
{
|
|
|
|
|
$this->update(['mfa_app_secret' => $secret]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getAppAuthenticationHolderName(): string
|
|
|
|
|
{
|
|
|
|
|
return $this->email;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return array<string>|null
|
|
|
|
|
*/
|
|
|
|
|
public function getAppAuthenticationRecoveryCodes(): ?array
|
|
|
|
|
{
|
|
|
|
|
return $this->mfa_app_recovery_codes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param array<string>|null $codes
|
|
|
|
|
*/
|
|
|
|
|
public function saveAppAuthenticationRecoveryCodes(?array $codes): void
|
|
|
|
|
{
|
|
|
|
|
$this->update(['mfa_app_recovery_codes' => $codes]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function hasEmailAuthentication(): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->mfa_email_enabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function toggleEmailAuthentication(bool $condition): void
|
2025-04-04 12:08:43 -04:00
|
|
|
{
|
2025-09-08 13:12:33 -04:00
|
|
|
$this->update(['mfa_email_enabled' => $condition]);
|
2025-04-04 12:08:43 -04:00
|
|
|
}
|
2015-12-06 13:58:49 -05:00
|
|
|
}
|