Skip to content

Commit

Permalink
Fix for #953
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Apr 3, 2019
1 parent d79fe75 commit ebf98ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions app/sprinkles/account/src/Controller/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -913,12 +913,9 @@ public function register(Request $request, Response $response, $args)
// Now that we check the form, we can register the actual user
$registration = new Registration($this->ci, $data);

try {
$user = $registration->register();
} catch (\Exception $e) {
$ms->addMessageTranslated('danger', $e->getMessage(), $data);
return $response->withJson([], 400);
}
// Try registration. An HttpException will be thrown if it fails
// No need to catch, as this kind of exception will automatically returns the addMessageTranslated
$user = $registration->register();

// Success message
if ($config['site.registration.require_email_verification']) {
Expand Down
2 changes: 1 addition & 1 deletion app/sprinkles/account/tests/Unit/RegistrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function testNormalRegistration()

// We try to register the same user again. Should throw an error
$registration = new Registration($this->ci, $fakeUserData);
$this->expectException(HttpException::class);
$this->expectException(HttpException::class); // @Todo : need to validate a message is trown
$validation = $registration->validate();

/**
Expand Down

0 comments on commit ebf98ae

Please sign in to comment.