Skip to content

Commit

Permalink
Fix reactiving of soft-deleted users
Browse files Browse the repository at this point in the history
The deactivate user action soft-deletes users in the DB. This allows the `attemptActivation()` method to restore users who were deactivated this way.

Fixes #382.
  • Loading branch information
Ben Thomson committed Jun 22, 2019
1 parent e742c57 commit 9edc955
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,18 @@ class User extends UserBase
*/
public function attemptActivation($code)
{
$result = parent::attemptActivation($code);
if ($result === false) {
return false;
if ($this->trashed()) {
if ($code == $this->activation_code) {

This comment has been minimized.

Copy link
@LukeTowers

LukeTowers Sep 2, 2019

Contributor

@bennothommo what's the reason for the double equals here instead of a triple?

This comment has been minimized.

Copy link
@bennothommo

bennothommo Sep 3, 2019

Author Contributor

@LukeTowers I think I literally just copied the line from here: https://github.com/octobercms/library/blob/develop/src/Auth/Models/User.php#L235. I assumed there was a reason it was double equals there too, but as far as I can see, there likely isn't, as both values should be strings.

This comment has been minimized.

Copy link
@LukeTowers

LukeTowers Sep 3, 2019

Contributor

@bennothommo when you get some time could you update both places? There's pretty much never a good reason to use == over ===

This comment has been minimized.

Copy link
@bennothommo

bennothommo Sep 3, 2019

Author Contributor

Will do :)

This comment has been minimized.

Copy link
@bennothommo

bennothommo Sep 3, 2019

Author Contributor
$this->restore();
} else {
return false;
}
} else {
$result = parent::attemptActivation($code);

if ($result === false) {
return false;
}
}

Event::fire('rainlab.user.activate', [$this]);
Expand Down

0 comments on commit 9edc955

Please sign in to comment.