You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is probably happening because it's attempting to set the group_id column as integer zero when creating the user which does not exist as a valid group_id in the groups table. I believe group_id should be excluded from the payload above to effectively leave the group_id value NULL when creating a user that doesn't belong to a group.
If a user must have a group, then the fix would be to remove the "No group" option from the Group dropdown in the "create a new user" modal.
Steps To Reproduce
Log into the userfrosting admin panel
Navigate to Users
Click Create user
Fill out the form in the resulting modal selecting "No group" from the Group dropdown.
Click Create
Ajax request to /api/users results in a 500 error
The text was updated successfully, but these errors were encountered:
Affected sprinkle or package
userfrosting/admin
UserFrosting or package Version
5.0.0
Debug Data
Chat Discussion (optional)
No response
Description
When attempting to create a user via the admin dashboard without a Group specified, the AJAX request to /api/users results in a 500 error.
Exception thrown:
[ { "type": "Illuminate\\Database\\QueryException", "code": "23000", "message": "SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
userfrosting.
users, CONSTRAINT
users_group_id_foreignFOREIGN KEY (
group_id) REFERENCES
groups(
id) ON DELETE RESTRICT ON UPDATE RESTRICT) (SQL: insert into
users(
user_name,
group_id,
first_name,
last_name,
email,
locale,
password,
flag_verified,
flag_enabled,
updated_at,
created_at) values (test_user, 0, , , test@userfrosting.com, en_US, $2y$10$f9ngAxbkFhlaSU7HUgre6um/42buCd7uMLY5NUoT1I.7ECl3yuFy6, 1, 1, 2024-10-03 11:25:35, 2024-10-03 11:25:35))", "file": "/app/vendor/illuminate/database/Connection.php", "line": 712 }, { "type": "PDOException", "code": "23000", "message": "SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
userfrosting.
users, CONSTRAINT
users_group_id_foreignFOREIGN KEY (
group_id) REFERENCES
groups(
id) ON DELETE RESTRICT ON UPDATE RESTRICT)", "file": "/app/vendor/illuminate/database/Connection.php", "line": 501 } ]
Request payload
csrf_name: csrf_value: user_name: test_user group_id: 0 first_name: last_name: email: test@userfrosting.com locale: en_US change_password_mode: manual password: [redacted] passwordc: [redacted]
This is probably happening because it's attempting to set the
group_id
column as integer zero when creating the user which does not exist as a validgroup_id
in thegroups
table. I believe group_id should be excluded from the payload above to effectively leave thegroup_id
value NULL when creating a user that doesn't belong to a group.If a user must have a group, then the fix would be to remove the "No group" option from the Group dropdown in the "create a new user" modal.
Steps To Reproduce
The text was updated successfully, but these errors were encountered: