Skip to content

Commit

Permalink
Merge pull request #143 from mettle/feature/automatic-invitation-acce…
Browse files Browse the repository at this point in the history
…ptance

[Feature] Automatic Invitation Acceptance For Existing Users
  • Loading branch information
JonoB authored Apr 30, 2021
2 parents 8c3e44f + 8b77520 commit d341874
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
10 changes: 10 additions & 0 deletions app/Services/Workspaces/SendInvitation.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ public function handle(Workspace $workspace, string $email): Invitation

$invitation = $this->createInvitation($workspace, $email, Workspace::ROLE_MEMBER, $existingUser);

if ($existingUser) {
// If there is an existing user, we are just going to automatically accept the invitation. This avoids
// needing to support displaying workspace invitation management to users who are not part of any existing
// workspace, but also just makes sense, as it isn't likely that anyone already signed up to a SendPortal
// instance would really want to reject an invitation in the first place, so we remove friction here.
/** @var AcceptInvitation $acceptInvitation */
$acceptInvitation = app(AcceptInvitation::class);
$acceptInvitation->handle($existingUser, $invitation);
}

$this->emailInvitation($invitation);

return $invitation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{{__('Hi!')}}
<p>{{__('Hi!')}}</p>

<br><br>
<p>{{__(':userName has added you to their workspace on SendPortal!', ['userName' => $invitation->workspace->owner->name])}}</p>

{{__(':userName has invited you to join their workspace on SendPortal!', ['userName' => $invitation->workspace->owner->name])}}
<p>{{__('Since you already have an account, you have automatically been added to the workspace.')}}</p>

<br><br>

{{__('Since you already have an account, you may accept the invitation from your account settings screen.')}}

<br><br>

{{__('See you soon!')}}
<p>{{__('See you soon!')}}</p>
20 changes: 9 additions & 11 deletions resources/views/workspaces/emails/invitation-to-new-user.blade.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{{__('Hi!')}}
<p>{{__('Hi!')}}</p>

<br><br>
<p>
{{__(':userName has invited you to join their workspace on SendPortal!', ['userName' => $invitation->workspace->owner->name])}}
{{__('If you do not already have an account, you may click the following link to get started:')}}
</p>

{{__(':userName has invited you to join their workspace on SendPortal!', ['userName' => $invitation->workspace->owner->name])}}
{{__('If you do not already have an account, you may click the following link to get started:')}}
<p>
<a href="{{ url('register?invitation='.$invitation->token) }}">{{ url('register?invitation='.$invitation->token) }}</a>
</p>

<br><br>

<a href="{{ url('register?invitation='.$invitation->token) }}">{{ url('register?invitation='.$invitation->token) }}</a>

<br><br>

{{__('See you soon!')}}
<p>{{__('See you soon!')}}</p>

0 comments on commit d341874

Please sign in to comment.