@@ -19,8 +19,8 @@ trait Resettable
1919 */
2020 public function requiresPasswordReset (): bool
2121 {
22- $ identity_model = model (UserIdentityModel::class);
23- $ identity = $ identity_model ->getIdentityByType ($ this , Session::ID_TYPE_EMAIL_PASSWORD );
22+ $ identityModel = model (UserIdentityModel::class);
23+ $ identity = $ identityModel ->getIdentityByType ($ this , Session::ID_TYPE_EMAIL_PASSWORD );
2424
2525 return $ identity ->force_reset ;
2626 }
@@ -35,11 +35,7 @@ public function forcePasswordReset(): void
3535 return ;
3636 }
3737
38- // Set force_reset to true
39- $ identity_model = model (UserIdentityModel::class);
40- $ identity_model ->set ('force_reset ' , 1 );
41- $ identity_model ->where (['user_id ' => $ this ->id , 'type ' => Session::ID_TYPE_EMAIL_PASSWORD ]);
42- $ identity_model ->update ();
38+ $ this ->setForceReset (true );
4339 }
4440
4541 /**
@@ -52,10 +48,19 @@ public function undoForcePasswordReset(): void
5248 return ;
5349 }
5450
55- // Set force_reset to false
56- $ identity_model = model (UserIdentityModel::class);
57- $ identity_model ->set ('force_reset ' , 0 );
58- $ identity_model ->where (['user_id ' => $ this ->id , 'type ' => Session::ID_TYPE_EMAIL_PASSWORD ]);
59- $ identity_model ->update ();
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+
61+ $ identityModel = model (UserIdentityModel::class);
62+ $ identityModel ->set ('force_reset ' , $ value );
63+ $ identityModel ->where (['user_id ' => $ this ->id , 'type ' => Session::ID_TYPE_EMAIL_PASSWORD ]);
64+ $ identityModel ->update ();
6065 }
6166}
0 commit comments