* Fixed #6956 - Added additional gates show showing/hiding license keys * Modified gate to allow user to see licenses if they can create or edit the license as well
This commit is contained in:
parent
23fa5d0bf4
commit
d016076806
8 changed files with 58 additions and 13 deletions
|
@ -179,7 +179,9 @@ class LicensesController extends Controller
|
||||||
$license->purchase_date = $request->input('purchase_date');
|
$license->purchase_date = $request->input('purchase_date');
|
||||||
$license->purchase_order = $request->input('purchase_order');
|
$license->purchase_order = $request->input('purchase_order');
|
||||||
$license->reassignable = $request->input('reassignable', 0);
|
$license->reassignable = $request->input('reassignable', 0);
|
||||||
|
if (Gate::allows('viewKeys', $license)) {
|
||||||
$license->serial = $request->input('serial');
|
$license->serial = $request->input('serial');
|
||||||
|
}
|
||||||
$license->termination_date = $request->input('termination_date');
|
$license->termination_date = $request->input('termination_date');
|
||||||
$license->seats = e($request->input('seats'));
|
$license->seats = e($request->input('seats'));
|
||||||
$license->manufacturer_id = $request->input('manufacturer_id');
|
$license->manufacturer_id = $request->input('manufacturer_id');
|
||||||
|
|
|
@ -14,15 +14,26 @@ class LicensePolicy extends CheckoutablePermissionsPolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether the user can view license keys
|
* Determine whether the user can view license keys.
|
||||||
|
* This gets a little tricky, UX/logic-wise. If a user has the ability
|
||||||
|
* to create a license (which requires a product key), shouldn't they
|
||||||
|
* have the ability to see the product key as well?
|
||||||
*
|
*
|
||||||
|
* Example: I create the license, realize I need to change
|
||||||
|
* something (maybe I got the product key wrong), and now I can never
|
||||||
|
* see/edit that product key.
|
||||||
|
*
|
||||||
|
* @see https://github.com/snipe/snipe-it/issues/6956
|
||||||
* @param \App\Models\User $user
|
* @param \App\Models\User $user
|
||||||
* @param \App\Models\License $license
|
* @param \App\Models\License $license
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function viewKeys(User $user, License $license = null)
|
public function viewKeys(User $user, License $license = null)
|
||||||
{
|
{
|
||||||
return $user->hasAccess('licenses.keys');
|
if ($user->hasAccess('licenses.keys') || $user->hasAccess('licenses.create') || $user->hasAccess('licenses.edit')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,13 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-2 control-label">{{ trans('admin/hardware/form.serial') }}</label>
|
<label class="col-sm-2 control-label">{{ trans('admin/hardware/form.serial') }}</label>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<p class="form-control-static">{{ $licenseSeat->license->serial }}</p>
|
<p class="form-control-static">
|
||||||
|
@can('viewKeys', $licenseSeat->license)
|
||||||
|
{{ $licenseSeat->license->serial }}
|
||||||
|
@else
|
||||||
|
------------
|
||||||
|
@endcan
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,13 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">{{ trans('admin/hardware/form.serial') }}</label>
|
<label class="col-sm-3 control-label">{{ trans('admin/hardware/form.serial') }}</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<p class="form-control-static" style="word-wrap: break-word;">{{ $license->serial }}</p>
|
<p class="form-control-static" style="word-wrap: break-word;">
|
||||||
|
@can('viewKeys', $license)
|
||||||
|
{{ $license->serial }}
|
||||||
|
@else
|
||||||
|
------------
|
||||||
|
@endcan
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,10 @@
|
||||||
@section('inputFields')
|
@section('inputFields')
|
||||||
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/licenses/form.name')])
|
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/licenses/form.name')])
|
||||||
@include ('partials.forms.edit.category-select', ['translated_name' => trans('admin/categories/general.category_name'), 'fieldname' => 'category_id', 'required' => 'true', 'category_type' => 'license'])
|
@include ('partials.forms.edit.category-select', ['translated_name' => trans('admin/categories/general.category_name'), 'fieldname' => 'category_id', 'required' => 'true', 'category_type' => 'license'])
|
||||||
|
|
||||||
|
|
||||||
<!-- Serial-->
|
<!-- Serial-->
|
||||||
|
@can('viewKeys', $item)
|
||||||
<div class="form-group {{ $errors->has('serial') ? ' has-error' : '' }}">
|
<div class="form-group {{ $errors->has('serial') ? ' has-error' : '' }}">
|
||||||
<label for="serial" class="col-md-3 control-label">{{ trans('admin/licenses/form.license_key') }}</label>
|
<label for="serial" class="col-md-3 control-label">{{ trans('admin/licenses/form.license_key') }}</label>
|
||||||
<div class="col-md-7{{ (\App\Helpers\Helper::checkIfRequired($item, 'serial')) ? ' required' : '' }}">
|
<div class="col-md-7{{ (\App\Helpers\Helper::checkIfRequired($item, 'serial')) ? ' required' : '' }}">
|
||||||
|
@ -18,6 +21,7 @@
|
||||||
{!! $errors->first('serial', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
{!! $errors->first('serial', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@endcan
|
||||||
|
|
||||||
<!-- Seats -->
|
<!-- Seats -->
|
||||||
<div class="form-group {{ $errors->has('seats') ? ' has-error' : '' }}">
|
<div class="form-group {{ $errors->has('seats') ? ' has-error' : '' }}">
|
||||||
|
|
|
@ -51,7 +51,13 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ is_null($license->company) ? '' : $license->company->name }}</td>
|
<td>{{ is_null($license->company) ? '' : $license->company->name }}</td>
|
||||||
<td>{{ $license->name }}</td>
|
<td>{{ $license->name }}</td>
|
||||||
<td>{{ mb_strimwidth($license->serial, 0, 50, "...") }}</td>
|
<td>
|
||||||
|
@can('viewKeys', $license)
|
||||||
|
{{ $license->serial }}
|
||||||
|
@else
|
||||||
|
------------
|
||||||
|
@endcan
|
||||||
|
</td>
|
||||||
<td>{{ $license->seats }}</td>
|
<td>{{ $license->seats }}</td>
|
||||||
<td>{{ $license->remaincount() }}</td>
|
<td>{{ $license->remaincount() }}</td>
|
||||||
<td>{{ $license->expiration_date }}</td>
|
<td>{{ $license->expiration_date }}</td>
|
||||||
|
|
|
@ -117,7 +117,13 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $lcounter }}</td>
|
<td>{{ $lcounter }}</td>
|
||||||
<td>{{ $license->name }}</td>
|
<td>{{ $license->name }}</td>
|
||||||
<td>{{ $license->serial }}</td>
|
<td>
|
||||||
|
@can('viewKeys', $license)
|
||||||
|
{{ $license->serial }}
|
||||||
|
@else
|
||||||
|
------------
|
||||||
|
@endcan
|
||||||
|
</td>
|
||||||
<td>{{ $license->assetlog->first()->created_at }}</td>
|
<td>{{ $license->assetlog->first()->created_at }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@php
|
@php
|
||||||
|
|
|
@ -375,7 +375,11 @@
|
||||||
{!! $license->present()->nameUrl() !!}
|
{!! $license->present()->nameUrl() !!}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
@can('viewKeys', $license)
|
||||||
{!! $license->present()->serialUrl() !!}
|
{!! $license->present()->serialUrl() !!}
|
||||||
|
@else
|
||||||
|
------------
|
||||||
|
@endcan
|
||||||
</td>
|
</td>
|
||||||
<td class="hidden-print">
|
<td class="hidden-print">
|
||||||
@can('update', $license)
|
@can('update', $license)
|
||||||
|
|
Loading…
Add table
Reference in a new issue