fix(team): send working invitation links to users without a password

Re-inviting an email after its invitation expired, or re-inviting a user
who never set a password, sent a link that needs a login the user cannot
complete. Unused invited accounts now get a magic link again, and changing
another user's password no longer ends the current session.
This commit is contained in:
Andras Bacsai
2026-10-29 17:54:17 +01:00
parent b41ba87fff
commit 6030d096bf
4 changed files with 124 additions and 30 deletions
+13 -11
View File
@@ -216,19 +216,21 @@ class User extends Authenticatable implements PasskeyUser, SendsEmail
*/
public function deleteIfNotVerifiedAndForcePasswordReset(): void
{
if ($this->hasVerifiedEmail() || $this->force_password_reset !== true) {
return;
if ($this->isUnusedInvitedAccount()) {
$this->delete();
}
}
if (TeamInvitation::whereEmail($this->email)->exists()) {
return;
}
if ($this->belongsToNonPersonalTeam()) {
return;
}
$this->delete();
/**
* Whether an invitation created this account and nobody uses it: the owner never set a password,
* it has no pending invitations, and it belongs to no team other than its own personal team.
*/
public function isUnusedInvitedAccount(): bool
{
return ! $this->hasVerifiedEmail()
&& $this->force_password_reset === true
&& ! TeamInvitation::whereEmail($this->email)->exists()
&& ! $this->belongsToNonPersonalTeam();
}
/**