mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-16 12:12:15 +01:00
Compare commits
1 Commits
feature/fi
...
3fd632fbdc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fd632fbdc |
@@ -23,10 +23,6 @@ class InvitationService
|
|||||||
*/
|
*/
|
||||||
public function inviteUser(Organization $organization, string $email, Role $role, User $inviter): OrganizationInvitation
|
public function inviteUser(Organization $organization, string $email, Role $role, User $inviter): OrganizationInvitation
|
||||||
{
|
{
|
||||||
// Normalize the email so it matches how user emails are stored (see UserService::createUser),
|
|
||||||
// otherwise a mixed-case invite silently fails to link on registration.
|
|
||||||
$email = strtolower($email);
|
|
||||||
|
|
||||||
if (app(MemberService::class)->isEmailAlreadyMember($organization, $email)) {
|
if (app(MemberService::class)->isEmailAlreadyMember($organization, $email)) {
|
||||||
throw new UserIsAlreadyMemberOfOrganizationApiException;
|
throw new UserIsAlreadyMemberOfOrganizationApiException;
|
||||||
}
|
}
|
||||||
@@ -59,7 +55,7 @@ class InvitationService
|
|||||||
$organizations = new Collection;
|
$organizations = new Collection;
|
||||||
|
|
||||||
$invitations = OrganizationInvitation::query()
|
$invitations = OrganizationInvitation::query()
|
||||||
->whereRaw('lower(email) = ?', [strtolower($user->email)])
|
->where('email', $user->email)
|
||||||
->whereNotNull('accepted_at')
|
->whereNotNull('accepted_at')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
"ext-zip": "*",
|
"ext-zip": "*",
|
||||||
"brick/money": "^0.10.0",
|
"brick/money": "^0.10.0",
|
||||||
"datomatic/laravel-enum-helper": "^2.0.0",
|
"datomatic/laravel-enum-helper": "^2.0.0",
|
||||||
"dedoc/scramble": "^0.12.2",
|
"dedoc/scramble": "^0.13.35",
|
||||||
"filament/filament": "^3.2",
|
"filament/filament": "^3.2",
|
||||||
"flowframe/laravel-trend": "^0.4.0",
|
"flowframe/laravel-trend": "^0.5.0",
|
||||||
"gotenberg/gotenberg-php": "^2.8",
|
"gotenberg/gotenberg-php": "^2.8",
|
||||||
"guzzlehttp/guzzle": "^7.2",
|
"guzzlehttp/guzzle": "^7.2",
|
||||||
"inertiajs/inertia-laravel": "^2.0.3",
|
"inertiajs/inertia-laravel": "^2.0.3",
|
||||||
|
|||||||
886
composer.lock
generated
886
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -380,40 +380,6 @@ class RegistrationTest extends TestCaseWithDatabase
|
|||||||
$this->assertSame($user->organization->id, $organizations->first()->id);
|
$this->assertSame($user->organization->id, $organizations->first()->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_registration_joins_invited_organization_even_if_invitation_email_casing_differs(): void
|
|
||||||
{
|
|
||||||
// Arrange: invitation stored with a different casing than the registration email
|
|
||||||
$user = $this->createUserWithPermission();
|
|
||||||
OrganizationInvitation::factory()
|
|
||||||
->forOrganization($user->organization)
|
|
||||||
->role(Role::Employee)
|
|
||||||
->accepted()
|
|
||||||
->create([
|
|
||||||
'email' => 'Invited.User@example.com',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
$response = $this->post('/register', [
|
|
||||||
'name' => 'Invited User',
|
|
||||||
'email' => 'invited.user@example.com',
|
|
||||||
'password' => 'password',
|
|
||||||
'password_confirmation' => 'password',
|
|
||||||
'terms' => true,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Assert: joined the inviting organization, no extra personal organization, invitation consumed
|
|
||||||
$this->assertAuthenticated();
|
|
||||||
$response->assertRedirect(RouteServiceProvider::HOME);
|
|
||||||
$newUser = User::where('email', 'invited.user@example.com')->first();
|
|
||||||
$this->assertNotNull($newUser);
|
|
||||||
$this->assertDatabaseMissing(OrganizationInvitation::class, [
|
|
||||||
'email' => 'Invited.User@example.com',
|
|
||||||
]);
|
|
||||||
$organizations = $newUser->organizations;
|
|
||||||
$this->assertCount(1, $organizations);
|
|
||||||
$this->assertSame($user->organization->id, $organizations->first()->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_registration_logs_and_skips_accepted_invitation_with_invalid_role(): void
|
public function test_registration_logs_and_skips_accepted_invitation_with_invalid_role(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|||||||
Reference in New Issue
Block a user