Skip to content

Commit

Permalink
Always invalidate all user email tokens
Browse files Browse the repository at this point in the history
Reported by B. Dhiyaneshwaran of Geek Freak.
  • Loading branch information
franzliedke committed Nov 28, 2018
1 parent 546b4f0 commit 66607a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/User/Command/ConfirmEmailHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public function handle(ConfirmEmail $command)
$user->save();
$this->dispatchEventsFor($user);

$token->delete();
// Delete *all* tokens for the user, in case other ones were sent first
$user->emailTokens()->delete();

return $user;
}
Expand Down
10 changes: 10 additions & 0 deletions src/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,16 @@ public function notifications()
return $this->hasMany('Flarum\Notification\Notification');
}

/**
* Define the relationship with the user's email tokens.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function emailTokens()
{
return $this->hasMany(EmailToken::class);
}

/**
* Define the relationship with the permissions of all of the groups that
* the user is in.
Expand Down

0 comments on commit 66607a5

Please sign in to comment.