Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Registration fails when trying to register two accounts with the same email address #953

Closed
lcharette opened this issue Apr 2, 2019 · 1 comment
Labels
confirmed bug Something isn't working
Milestone

Comments

@lcharette
Copy link
Member

Ref.: https://forums.userfrosting.com/t/php-error-undefined-variable-if-new-user-registration-fails/507/1

The simplest way to reproduce is to try to register two accounts with the same email address. Note this doesn't happens when creating a user manually through the admin panel.

Error message:

{
    "message": "Call to a member function toArray() on null",
    "exception": [
        {
            "type": "Error",
            "code": 0,
            "message": "Call to a member function toArray() on null",
            "file": "\/home\/vagrant\/UserFrosting\/app\/sprinkles\/account\/src\/Controller\/AccountController.php",
            "line": 926
        }
    ]
}
@lcharette lcharette added the confirmed bug Something isn't working label Apr 2, 2019
@lcharette lcharette added this to the 4.2.x milestone Apr 2, 2019
@lcharette
Copy link
Member Author

That's new level of bad code. If an exception is thrown, a success is still displayed 🤦‍♂️

try {
$user = $registration->register();
} catch (\Exception $e) {
$ms->addMessageTranslated('danger', $e->getMessage(), $data);
$error = true;
}
// Success message
if ($config['site.registration.require_email_verification']) {
// Verification required
$ms->addMessageTranslated('success', 'REGISTRATION.COMPLETE_TYPE2', $user->toArray());
} else {
// No verification required
$ms->addMessageTranslated('success', 'REGISTRATION.COMPLETE_TYPE1');
}
return $response->withJson([], 200);

lcharette added a commit that referenced this issue Apr 3, 2019
lcharette added a commit that referenced this issue Apr 3, 2019
@lcharette lcharette mentioned this issue Apr 5, 2019
@lcharette lcharette modified the milestones: 4.2.x, 4.2.1 Apr 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant