Unable to edit current user permissions v3.0
Expected Behavior (or desired behavior if a feature request)
Admin user should have super user access to Snipe.
Actual Behavior
Admin users are unable to see anything other than their own asset page. I go to the user and choose the permissions tab and select grant super user and when I save I get these errors.
Please confirm you have done the following before posting your bug report:
- [x ] I have enabled debug mode
- [x ] I have read checked the Common Issues page
Please provide answers to these questions before posting your bug report:
- Version of Snipe-IT you're running- v3.0
- What OS and web server you're running Snipe-IT on- Server 2012 R2, IIS
- What method you used to install Snipe-IT (install.sh, manual installation, docker, etc)- Manual Install
- If you're getting an error in your browser, include that error--Shows 2 errors
1/2
PDOException in Connection.php line 431:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (snipeit_laravel.users, CONSTRAINT users_company_id_foreign FOREIGN KEY (company_id) REFERENCES companies (id))
2/2
QueryException in Connection.php line 673:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (snipeit_laravel.users, CONSTRAINT users_company_id_foreign FOREIGN KEY (company_id) REFERENCES companies (id)) (SQL: update users set permissions = {"superuser":"1","admin":"0","reports.view":"0","licenses.keys":"0"}, updated_at = 2016-05-20 17:54:33, company_id = where id = 3)
- What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error- User>Permissions tab>Save new permission
This was a migration to v3.0 not a new install.
The group all of the admin users are in is called Admin, when I go in to edit the group I get an error but all other groups are fine and I am able to create other groups.
What version were you upgrading from?
2.1.0
Weird... that company_id foreign key constraint should have been removed in much earlier migrations.
I think I started at v2.0 so no telling what I may of accidentally messed with at each upgrade.
It's not your fault. There was a bad migration in a PR a long time ago (when company scoping was introduced), and it was breaking on some people's machines. I thought I fixed that a while ago (per #1400), so I'm not sure what's going on.
Weird, it won't let me edit them either, otherwise I would just edit their email address and put them in a new group. Will try and find a workaround for now. Thanks!
Do you have access to the DB via phpmyadmin or anything?
Yes ive got workbench on here.
Can you show me a screenshot of the structure of your users table?
Can you disclose the foreign keys section for me?
Can you delete that foreign key and try editing the user again?
(That foreign key has been the bane of my existence.... sigh.)
How do I delete, I right click and the only options are to Create Schema.. or Refresh all, weird.
ALTER TABLE users DROP FOREIGN KEY users_company_id_foreign;
(I don't use Workbench, so I'm not sure how they want you to do it.)