mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
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:
+13
-11
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user