Skip to content

Commit

Permalink
Change order of logged register/email sent events
Browse files Browse the repository at this point in the history
  • Loading branch information
carlbennett committed Aug 23, 2019
1 parent 20a55fe commit 8f541cb
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions src/controllers/User/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,25 @@ protected function tryRegister(Router &$router, UserRegisterModel &$model) {

}

if ($success) {
if (!$success) {
$model->error = 'INTERNAL_ERROR';
} else {
$model->error = false;

Logger::logEvent(
EventTypes::USER_CREATED,
$user_id,
getenv("REMOTE_ADDR"),
json_encode([
"error" => $model->error,
"requirements" => $req,
"email" => $email,
"username" => $username,
"display_name" => null,
"options_bitmask" => 0,
])
);

$state = new StdClass();

$mail = new PHPMailer( true ); // true enables exceptions
Expand Down Expand Up @@ -239,25 +257,6 @@ protected function tryRegister(Router &$router, UserRegisterModel &$model) {
$model->error = "EMAIL_FAILURE";
}
}

if (!$success) {
$model->error = "INTERNAL_ERROR";
} else {
$model->error = false;
}
Logger::logEvent(
EventTypes::USER_CREATED,
$user_id,
getenv("REMOTE_ADDR"),
json_encode([
"error" => $model->error,
"requirements" => $req,
"email" => $email,
"username" => $username,
"display_name" => null,
"options_bitmask" => 0,
])
);
}

}

0 comments on commit 8f541cb

Please sign in to comment.