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

Comments

Projects
None yet
1 participant
@lcharette
Copy link
Member

commented Apr 2, 2019

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 this to the 4.2.x milestone Apr 2, 2019

@lcharette

This comment has been minimized.

Copy link
Member Author

commented Apr 3, 2019

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 referenced this issue Apr 5, 2019

Merged

Fix #953 #955

lcharette added a commit that referenced this issue Apr 5, 2019

@lcharette lcharette closed this Apr 9, 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
You can’t perform that action at this time.