mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-21 20:24:06 +00:00
Support invitations for unregistered users
When inviting an email without an InvoiceShelf account, the email now
links to a registration page (/register?invitation={token}) instead of
login. After registering, the invitation is auto-accepted.
Backend:
- InvitationRegistrationController: public details() and register()
endpoints. Registration validates token + email match, creates account,
auto-accepts invitation, returns Sanctum token.
- AuthController: login now accepts optional invitation_token param to
auto-accept invitation for existing users clicking the email link.
- CompanyInvitationMail: conditional URL based on user existence.
- Web route for /invitations/{token}/decline (email decline link).
Frontend:
- RegisterWithInvitation.vue: fetches invitation details, shows company
name + role, registration form with pre-filled email.
- Router: /register route added.
Tests: 3 new tests (invitation details, register + accept, email mismatch).
This commit is contained in:
@@ -28,6 +28,13 @@ class CompanyInvitationMail extends Mailable
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
$token = $this->invitation->token;
|
||||
$hasAccount = $this->invitation->user_id !== null;
|
||||
|
||||
$acceptUrl = $hasAccount
|
||||
? url("/login?invitation={$token}")
|
||||
: url("/register?invitation={$token}");
|
||||
|
||||
return new Content(
|
||||
markdown: 'emails.company-invitation',
|
||||
with: [
|
||||
@@ -35,8 +42,9 @@ class CompanyInvitationMail extends Mailable
|
||||
'companyName' => $this->invitation->company->name,
|
||||
'roleName' => $this->invitation->role->title,
|
||||
'inviterName' => $this->invitation->invitedBy->name,
|
||||
'acceptUrl' => url("/invitations/{$this->invitation->token}/accept"),
|
||||
'declineUrl' => url("/invitations/{$this->invitation->token}/decline"),
|
||||
'acceptUrl' => $acceptUrl,
|
||||
'declineUrl' => url("/invitations/{$token}/decline"),
|
||||
'hasAccount' => $hasAccount,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user