Skip to content

Commit ebf98ae

Browse files
committed
Fix for #953
1 parent d79fe75 commit ebf98ae

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

app/sprinkles/account/src/Controller/AccountController.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -913,12 +913,9 @@ public function register(Request $request, Response $response, $args)
913913
// Now that we check the form, we can register the actual user
914914
$registration = new Registration($this->ci, $data);
915915

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

923920
// Success message
924921
if ($config['site.registration.require_email_verification']) {

app/sprinkles/account/tests/Unit/RegistrationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function testNormalRegistration()
7878

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

8484
/**

0 commit comments

Comments
 (0)