Skip to content

Commit 87483ee

Browse files
committed
Add a default option constant to User class
1 parent 23b7f52 commit 87483ee

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/controllers/User/Register.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,28 @@ protected function tryRegister(Router &$router, UserRegisterModel &$model) {
127127
$model->error = "REGISTER_DISABLED";
128128
return;
129129
}
130+
130131
try {
131132
if (!$req->email_duplicate_allowed && User::findIdByEmail($email)) {
132133
$model->error = "EMAIL_ALREADY_USED";
133134
return;
134135
}
135136
} catch (UserNotFoundException $e) {}
137+
136138
try {
137-
$success = User::create($email, $username, null, $pw1, 0);
139+
140+
$success = User::create(
141+
$email, $username, null, $pw1, User::DEFAULT_OPTION
142+
);
143+
138144
} catch (QueryException $e) {
145+
139146
// SQL error occurred. We can show a friendly message to the user while
140147
// also notifying this problem to staff.
141148
Logger::logException($e);
149+
142150
}
151+
143152
if (!$success) {
144153
$model->error = "INTERNAL_ERROR";
145154
} else {

src/libraries/User.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
class User implements JsonSerializable {
2222

23+
const DEFAULT_OPTION = 0x00000020;
24+
2325
const OPTION_DISABLED = 0x00000001;
2426
const OPTION_VERIFIED = 0x00000002;
2527
const OPTION_ACL_DOCUMENT_CREATE = 0x00000004;

0 commit comments

Comments
 (0)