snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

Unable to edit current user permissions v3.0

Open zmorrow opened this issue 10 years ago • 29 comments

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:


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

zmorrow avatar May 20 '16 17:05 zmorrow

This was a migration to v3.0 not a new install.

zmorrow avatar May 20 '16 17:05 zmorrow

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.

zmorrow avatar May 20 '16 17:05 zmorrow

What version were you upgrading from?

snipe avatar May 20 '16 18:05 snipe

2.1.0

zmorrow avatar May 20 '16 18:05 zmorrow

Weird... that company_id foreign key constraint should have been removed in much earlier migrations.

snipe avatar May 20 '16 18:05 snipe

I think I started at v2.0 so no telling what I may of accidentally messed with at each upgrade.

zmorrow avatar May 20 '16 18:05 zmorrow

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.

snipe avatar May 20 '16 18:05 snipe

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!

zmorrow avatar May 20 '16 18:05 zmorrow

Do you have access to the DB via phpmyadmin or anything?

snipe avatar May 20 '16 18:05 snipe

Yes ive got workbench on here.

zmorrow avatar May 20 '16 18:05 zmorrow

Can you show me a screenshot of the structure of your users table?

snipe avatar May 20 '16 18:05 snipe

snipe1

zmorrow avatar May 20 '16 18:05 zmorrow

Can you disclose the foreign keys section for me?

snipe avatar May 20 '16 18:05 snipe

snipe2

zmorrow avatar May 20 '16 18:05 zmorrow

snipe3

zmorrow avatar May 20 '16 18:05 zmorrow

Can you delete that foreign key and try editing the user again?

snipe avatar May 20 '16 18:05 snipe

(That foreign key has been the bane of my existence.... sigh.)

snipe avatar May 20 '16 18:05 snipe

How do I delete, I right click and the only options are to Create Schema.. or Refresh all, weird.

zmorrow avatar May 20 '16 18:05 zmorrow

ALTER TABLE users DROP FOREIGN KEY users_company_id_foreign;

snipe avatar May 20 '16 18:05 snipe

(I don't use Workbench, so I'm not sure how they want you to do it.)

snipe avatar May 20 '16 18:05 snipe