Skip to content

Commit 83fd399

Browse files
committed
refactor: extract method
1 parent 097805f commit 83fd399

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/Traits/Resettable.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ public function forcePasswordReset(): void
3535
return;
3636
}
3737

38-
// Set force_reset to true
39-
$identityModel = model(UserIdentityModel::class);
40-
$identityModel->set('force_reset', 1);
41-
$identityModel->where(['user_id' => $this->id, 'type' => Session::ID_TYPE_EMAIL_PASSWORD]);
42-
$identityModel->update();
38+
$this->setForceReset(true);
4339
}
4440

4541
/**
@@ -52,9 +48,18 @@ public function undoForcePasswordReset(): void
5248
return;
5349
}
5450

55-
// Set force_reset to false
51+
$this->setForceReset(false);
52+
}
53+
54+
/**
55+
* Set force_reset
56+
*/
57+
private function setForceReset(bool $value): void
58+
{
59+
$value = (int) $value;
60+
5661
$identityModel = model(UserIdentityModel::class);
57-
$identityModel->set('force_reset', 0);
62+
$identityModel->set('force_reset', $value);
5863
$identityModel->where(['user_id' => $this->id, 'type' => Session::ID_TYPE_EMAIL_PASSWORD]);
5964
$identityModel->update();
6065
}

0 commit comments

Comments
 (0)