Skip to content

Commit e8d389d

Browse files
committed
Make isDisabled and isVerified functions in User
1 parent ba8cf2d commit e8d389d

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/controllers/User/Login.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ protected function tryLogin(Router &$router, UserLoginModel &$model) {
7676

7777
if (!$user) {
7878
$model->error = "USER_NOT_FOUND";
79-
} else if ($user->getOptionsBitmask() & User::OPTION_DISABLED) {
79+
} else if ($user->isDisabled()) {
8080
$model->error = "USER_DISABLED";
81-
} else if (!$user->getOptionsBitmask() & User::OPTION_VERIFIED) {
81+
} else if (!$user->isVerified()) {
8282
$model->error = "USER_NOT_VERIFIED";
8383
} else if (!$user->checkPassword($password)) {
8484
$model->error = "PASSWORD_INCORRECT";

src/controllers/User/ResetPassword.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ protected function doPasswordReset( UserResetPasswordModel &$model, &$data ) {
224224
$model->user->invalidateVerificationToken();
225225
// --
226226

227-
if ( $model->user->getAcl( User::OPTION_DISABLED )) {
227+
if ( $model->user->isDisabled() ) {
228228
$model->error = 'USER_DISABLED';
229229
return self::RET_FAILURE;
230230
}

src/libraries/User.php

+8
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,10 @@ public function invalidateVerificationToken() {
534534
return Common::$cache->delete($key);
535535
}
536536

537+
public function isDisabled() {
538+
return ($this->options_bitmask & self::OPTION_DISABLED);
539+
}
540+
537541
public function isStaff() {
538542
return ($this->options_bitmask & (
539543
self::OPTION_ACL_DOCUMENT_CREATE |
@@ -560,6 +564,10 @@ public function isStaff() {
560564
));
561565
}
562566

567+
public function isVerified() {
568+
return ($this->options_bitmask & self::OPTION_VERIFIED);
569+
}
570+
563571
public function jsonSerialize() {
564572
$created_datetime = $this->getCreatedDateTime();
565573
if (!is_null($created_datetime)) $created_datetime = [

0 commit comments

Comments
 (0)