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

Foreign Key constraint fails when an admin attempts to create a new user #1190

Merged
merged 2 commits into from
Jan 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/sprinkles/admin/src/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ public function create(Request $request, Response $response, array $args)
$data['group_id'] = $currentUser->group_id;
}

// 0 maps to "No group", database requires a NULL to avoid issues with foreign keys
if (isset($data['group_id']) && $data['group_id'] == 0) {
$data['group_id'] = null;
}

$data['flag_verified'] = 1;
if (!isset($data['password'])) {
// Set password as empty on initial creation. We will then send email so new user can set it themselves via a verification token
Expand Down