diff --git a/app/Models/Organization.php b/app/Models/Organization.php index 2297a0f0..26d1e270 100644 --- a/app/Models/Organization.php +++ b/app/Models/Organization.php @@ -27,8 +27,9 @@ * @property User $owner * @property Carbon|null $created_at * @property Carbon|null $updated_at - * @property Collection $users - * @property Collection $realUsers + * @property Collection $users + * @property Collection $realUsers + * @property-read Collection $teamInvitations * @property Membership $membership * * @method HasMany teamInvitations() @@ -83,7 +84,7 @@ class Organization extends JetstreamTeam /** * Get all the non-placeholder users of the organization including its owner. * - * @return Collection + * @return Collection */ public function allRealUsers(): Collection { diff --git a/app/Models/Project.php b/app/Models/Project.php index 1713fa02..48a78002 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -22,7 +22,7 @@ * @property int|null $billable_rate * @property-read Organization $organization * @property-read Client|null $client - * @property-read Collection $tasks + * @property-read Collection $tasks * * @method Builder visibleByUser(User $user) * @method static ProjectFactory factory() diff --git a/app/Models/Task.php b/app/Models/Task.php index 7e331e05..e868c93b 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -22,7 +22,7 @@ * @property Carbon|null $updated_at * @property-read Project $project * @property-read Organization $organization - * @property-read Collection $timeEntries + * @property-read Collection $timeEntries * * @method static TaskFactory factory() */ diff --git a/app/Providers/FortifyServiceProvider.php b/app/Providers/FortifyServiceProvider.php index 7a533eb3..bd5166d4 100644 --- a/app/Providers/FortifyServiceProvider.php +++ b/app/Providers/FortifyServiceProvider.php @@ -8,8 +8,10 @@ use App\Actions\Fortify\ResetUserPassword; use App\Actions\Fortify\UpdateUserPassword; use App\Actions\Fortify\UpdateUserProfileInformation; +use App\Models\User; use Illuminate\Cache\RateLimiting\Limit; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\RateLimiter; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Str; @@ -35,6 +37,20 @@ public function boot(): void Fortify::updateUserPasswordsUsing(UpdateUserPassword::class); Fortify::resetUserPasswordsUsing(ResetUserPassword::class); + Fortify::authenticateUsing(function (Request $request): ?User { + /** @var User|null $user */ + $user = User::query() + ->where('email', $request->email) + ->where('is_placeholder', '=', false) + ->first(); + + if ($user !== null && Hash::check($request->password, $user->password)) { + return $user; + } + + return null; + }); + RateLimiter::for('login', function (Request $request) { $throttleKey = Str::transliterate(Str::lower($request->input(Fortify::username())).'|'.$request->ip()); diff --git a/app/Providers/JetstreamServiceProvider.php b/app/Providers/JetstreamServiceProvider.php index f975e58f..6f192680 100644 --- a/app/Providers/JetstreamServiceProvider.php +++ b/app/Providers/JetstreamServiceProvider.php @@ -16,6 +16,7 @@ use App\Enums\Weekday; use App\Models\Organization; use App\Models\OrganizationInvitation; +use App\Models\User; use App\Service\TimezoneService; use Brick\Money\Currency; use Brick\Money\ISOCurrencyProvider; @@ -103,7 +104,7 @@ protected function configurePermissions(): void 'members:change-role', 'members:update', 'members:delete', - ])->description('Owner users can perform any action.'); + ])->description('Owner users can perform any action. There is only one owner per organization.'); Jetstream::role(Role::Admin->value, 'Administrator', [ 'projects:view', @@ -145,7 +146,7 @@ protected function configurePermissions(): void 'invitations:remove', 'members:view', 'members:invite-placeholder', - ])->description('Administrator users can perform any action.'); + ])->description('Administrator users can perform any action, except accessing the billing dashboard.'); Jetstream::role(Role::Manager->value, 'Manager', [ 'projects:view', @@ -181,7 +182,7 @@ protected function configurePermissions(): void 'organizations:view', 'invitations:view', 'members:view', - ])->description('Managers have the ability to read, create, and update their own time entries as well as those of their team.'); + ])->description('Managers have full access to all projects, time entries, ect. but cannot manage the organization (add/remove member, edit the organization, ect.).'); Jetstream::role(Role::Employee->value, 'Employee', [ 'projects:view', @@ -192,7 +193,7 @@ protected function configurePermissions(): void 'time-entries:update:own', 'time-entries:delete:own', 'organizations:view', - ])->description('Employees have the ability to read, create, and update their own time entries.'); + ])->description('Employees have the ability to read, create, and update their own time entries and they can see the projects that they are members of.'); Jetstream::role(Role::Placeholder->value, 'Placeholder', [ ])->description('Placeholders are used for importing data. They cannot log in and have no permissions.'); @@ -210,7 +211,41 @@ function (Request $request, array $data): array { ->whenRendering( 'Teams/Show', function (Request $request, array $data): array { + /** @var Organization $teamModel */ + $teamModel = $data['team']; + $owner = $teamModel->owner; + return array_merge($data, [ + 'team' => [ + 'id' => $teamModel->getKey(), + 'name' => $teamModel->name, + 'currency' => $teamModel->currency, + 'owner' => [ + 'id' => $owner->getKey(), + 'name' => $owner->name, + 'email' => $owner->email, + 'profile_photo_url' => $owner->profile_photo_url, + ], + 'users' => $teamModel->users->map(function (User $user): array { + return [ + 'id' => $user->getKey(), + 'name' => $user->name, + 'email' => $user->email, + 'profile_photo_url' => $user->profile_photo_url, + 'membership' => [ + 'id' => $user->membership->id, + 'role' => $user->membership->role, + ], + ]; + }), + 'team_invitations' => $teamModel->teamInvitations->map(function (OrganizationInvitation $invitation): array { + return [ + 'id' => $invitation->getKey(), + 'email' => $invitation->email, + 'role' => $invitation->role, + ]; + }), + ], 'currencies' => array_map(function (Currency $currency): string { return $currency->getName(); }, ISOCurrencyProvider::getInstance()->getAvailableCurrencies()), diff --git a/app/Service/Import/Importers/ClockifyTimeEntriesImporter.php b/app/Service/Import/Importers/ClockifyTimeEntriesImporter.php index f5ad09dd..a7e52ee5 100644 --- a/app/Service/Import/Importers/ClockifyTimeEntriesImporter.php +++ b/app/Service/Import/Importers/ClockifyTimeEntriesImporter.php @@ -162,12 +162,12 @@ private function validateHeader(array $header): void #[\Override] public function getName(): string { - return __('importer.toggl_data_importer.name'); + return __('importer.clockify_time_entries.name'); } #[\Override] public function getDescription(): string { - return __('importer.toggl_data_importer.description'); + return __('importer.clockify_time_entries.description'); } } diff --git a/resources/js/Pages/Teams/Partials/DeleteTeamForm.vue b/resources/js/Pages/Teams/Partials/DeleteTeamForm.vue index 65b55a7e..72c9370b 100644 --- a/resources/js/Pages/Teams/Partials/DeleteTeamForm.vue +++ b/resources/js/Pages/Teams/Partials/DeleteTeamForm.vue @@ -26,21 +26,21 @@ const deleteTeam = () => {