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

"Generate Labels" permissions

Open Jason-Weber-UC opened this issue 9 years ago • 10 comments

Other than making someone a super-admin, I cant seem give permissions to generate labels? screen shot 2017-05-10 at 2 40 20 pm

Jason-Weber-UC avatar May 10 '17 04:05 Jason-Weber-UC

I've just tried to create a user within the Demo (Jason Test) and give "Admin" permissions (as opposed to super-admin) and assign to a company. Also assigned a few assets to said company. Seems to be disabled.....

Jason-Weber-UC avatar May 10 '17 05:05 Jason-Weber-UC

Any help on this? It's kinda my last stumbling block (now that the fuzzy barcodes are sorted)

Jason-Weber-UC avatar May 12 '17 02:05 Jason-Weber-UC

Ok... digging through the code (remember: I'm NOT a programmer...)

It looks like the barcode generation uses getQrCode? Within getQrCode there is: if (!Company::isCurrentUserHasAccess($asset)) I cant seem to find any 'label specific' permissions, so I assume its just "Is the user allocated to the Company?" I have Full Multiple Companies Support enabled

Jason-Weber-UC avatar May 15 '17 03:05 Jason-Weber-UC

getQrCode() just gets an individual QR code for browser display/caching. I think this section is what's triggering your error. https://github.com/snipe/snipe-it/blob/master/app/Http/Controllers/AssetsController.php#L1418-L1420

That method calls:

public static function isCurrentUserAuthorized()
{
        return ((!static::isFullMultipleCompanySupportEnabled()) || (Auth::user()->isSuperUser()));
}

So yes, it looks like only superusers can generate labels IF full company support is enabled. I believe this has been resolved in the upcoming v4.

snipe avatar May 16 '17 04:05 snipe

Is there any fix/hack I can apply to v3?

Jason-Weber-UC avatar May 16 '17 04:05 Jason-Weber-UC

will ->isAdmin() work?

Jason-Weber-UC avatar May 16 '17 04:05 Jason-Weber-UC

Don't change the isCurrentUserAuthorized() method - that's an authorization method that could have much further-reaching impact than just labels, and could open things up to people being allowed to do things they're not supposed to be able to do.

If you have to make this work for v3, change:

if (!Company::isCurrentUserAuthorized()) {
  return redirect()->to('hardware')->with('error', trans('general.insufficient_permissions'));
} elseif (!Input::has('edit_asset')) {
   return redirect()->back()->with('error', 'No assets selected');
} else {
  $asset_raw_array = Input::get('edit_asset');
  
  foreach ($asset_raw_array as $asset_id => $value) {
      $asset_ids[] = $asset_id;
  }
}

location here: https://github.com/snipe/snipe-it/blob/master/app/Http/Controllers/AssetsController.php#L1418-L1431

to:

if (!Input::has('edit_asset')) {
    return redirect()->back()->with('error', 'No assets selected');
} else {
   $asset_raw_array = Input::get('edit_asset');
   
   foreach ($asset_raw_array as $asset_id => $value) {
       $asset_ids[] = $asset_id;
   }
}

snipe avatar May 16 '17 05:05 snipe

BEAUTIFUL!! THANK YOU so much

Jason-Weber-UC avatar May 16 '17 05:05 Jason-Weber-UC

No problem - glad that got you sorted.

hackers-gunslinger

snipe avatar May 16 '17 05:05 snipe

Gotta hack the Gibson

Jason-Weber-UC avatar May 16 '17 05:05 Jason-Weber-UC