Skip to content

Commit c73c2b0

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents a6d9c1f + 65b39d3 commit c73c2b0

File tree

7 files changed

+191
-124
lines changed

7 files changed

+191
-124
lines changed

app/Http/Controllers/Api/UsersController.php

Lines changed: 67 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -522,93 +522,99 @@ public function update(SaveUserRequest $request, User $user): JsonResponse
522522
{
523523
$this->authorize('update', User::class);
524524

525-
$this->authorize('update', $user);
525+
$this->authorize('update', $user);
526526

527-
/**
528-
* This is a janky hack to prevent people from changing admin demo user data on the public demo.
529-
* The $ids 1 and 2 are special since they are seeded as superadmins in the demo seeder.
530-
* Thanks, jerks. You are why we can't have nice things. - snipe
531-
*
532-
*/
527+
/**
528+
* This is a janky hack to prevent people from changing admin demo user data on the public demo.
529+
* The $ids 1 and 2 are special since they are seeded as superadmins in the demo seeder.
530+
* Thanks, jerks. You are why we can't have nice things. - snipe
531+
*
532+
*/
533533

534534
if ((($user->id == 1) || ($user->id == 2)) && (config('app.lock_passwords'))) {
535-
return response()->json(Helper::formatStandardApiResponse('error', null, 'Permission denied. You cannot update user information via API on the demo.'));
536-
}
535+
return response()->json(Helper::formatStandardApiResponse('error', null, 'Permission denied. You cannot update user information via API on the demo.'));
536+
}
537+
538+
// Pull out sensitive fields that require extra permission
539+
$user->fill($request->except(['password', 'username', 'email', 'activated', 'permissions', 'activation_code', 'remember_token', 'two_factor_secret', 'two_factor_enrolled', 'two_factor_optin']));
540+
537541

538-
$user->fill($request->all());
542+
if (auth()->user()->can('canEditAuthFields', $user) && auth()->user()->can('editableOnDemo')) {
539543

540-
if ($request->filled('company_id')) {
541-
$user->company_id = Company::getIdForCurrentUser($request->input('company_id'));
544+
if ($request->filled('password')) {
545+
$user->password = bcrypt($request->input('password'));
542546
}
543547

544-
if ($user->id == $request->input('manager_id')) {
545-
return response()->json(Helper::formatStandardApiResponse('error', null, 'You cannot be your own manager'));
548+
if ($request->filled('username')) {
549+
$user->username = $request->input('username');
546550
}
547551

548-
// check for permissions related fields and pull them out if the current user cannot edit them
549-
if (auth()->user()->can('canEditAuthFields', $user) && auth()->user()->can('editableOnDemo')) {
552+
if ($request->filled('email')) {
553+
$user->email = $request->input('email');
554+
}
550555

551-
if ($request->filled('password')) {
552-
$user->password = bcrypt($request->input('password'));
553-
}
556+
if ($request->filled('activated')) {
557+
$user->activated = $request->input('activated');
558+
}
554559

555-
if ($request->filled('username')) {
556-
$user->username = $request->input('username');
557-
}
560+
}
558561

559-
if ($request->filled('display_name')) {
560-
$user->display_name = $request->input('display_name');
561-
}
562+
// We need to use has() instead of filled()
563+
// here because we need to overwrite permissions
564+
// if someone needs to null them out
562565

563-
if ($request->filled('email')) {
564-
$user->email = $request->input('email');
565-
}
566+
if ($request->filled('display_name')) {
567+
$user->display_name = $request->input('display_name');
568+
}
566569

567-
if ($request->filled('activated')) {
568-
$user->activated = $request->input('activated');
569-
}
570+
if ($request->filled('company_id')) {
571+
$user->company_id = Company::getIdForCurrentUser($request->input('company_id'));
572+
}
570573

571-
}
574+
if ($user->id == $request->input('manager_id')) {
575+
return response()->json(Helper::formatStandardApiResponse('error', null, 'You cannot be your own manager'));
576+
}
572577

573-
// We need to use has() instead of filled()
574-
// here because we need to overwrite permissions
575-
// if someone needs to null them out
576-
if ($request->has('permissions')) {
577-
$permissions_array = $request->input('permissions');
578578

579-
// Strip out the individual superuser permission if the API user isn't a superadmin
580-
if (!auth()->user()->isSuperUser()) {
581-
unset($permissions_array['superuser']);
582-
}
579+
580+
if ($request->has('permissions')) {
581+
$permissions_array = $request->input('permissions');
583582

584-
$user->permissions = $permissions_array;
583+
// Strip out the individual superuser permission if the API user isn't a superadmin
584+
if (!auth()->user()->isSuperUser()) {
585+
unset($permissions_array['superuser']);
585586
}
586587

587-
if($request->has('location_id')) {
588-
// Update the location of any assets checked out to this user
589-
Asset::where('assigned_type', User::class)
590-
->where('assigned_to', $user->id)->update(['location_id' => $request->input('location_id', null)]);
591-
}
592-
app('App\Http\Requests\ImageUploadRequest')->handleImages($user, 600, 'avatar', 'avatars', 'avatar');
588+
$user->permissions = $permissions_array;
589+
}
590+
591+
if ($request->has('location_id')) {
592+
// Update the location of any assets checked out to this user
593+
Asset::where('assigned_type', User::class)
594+
->where('assigned_to', $user->id)->update(['location_id' => $request->input('location_id', null)]);
595+
}
593596

594-
if ($user->save()) {
595-
// Check if the request has groups passed and has a value, AND that the user us a superuser
596-
if (($request->has('groups')) && (auth()->user()->isSuperUser())) {
597597

598-
$validator = Validator::make($request->only('groups'), [
599-
'groups.*' => 'integer|exists:permission_groups,id',
600-
]);
598+
app('App\Http\Requests\ImageUploadRequest')->handleImages($user, 600, 'avatar', 'avatars', 'avatar');
601599

602-
if ($validator->fails()) {
603-
return response()->json(Helper::formatStandardApiResponse('error', null, $validator->errors()));
604-
}
600+
if ($user->save()) {
601+
// Check if the request has groups passed and has a value, AND that the user us a superuser
602+
if (($request->has('groups')) && (auth()->user()->isSuperUser())) {
603+
604+
$validator = Validator::make($request->only('groups'), [
605+
'groups.*' => 'integer|exists:permission_groups,id',
606+
]);
605607

606-
// Sync the groups since the user is a superuser and the groups pass validation
607-
$user->groups()->sync($request->input('groups'));
608+
if ($validator->fails()) {
609+
return response()->json(Helper::formatStandardApiResponse('error', null, $validator->errors()));
608610
}
609-
return response()->json(Helper::formatStandardApiResponse('success', (new UsersTransformer)->transformUser($user), trans('admin/users/message.success.update')));
611+
612+
// Sync the groups since the user is a superuser and the groups pass validation
613+
$user->groups()->sync($request->input('groups'));
610614
}
611-
return response()->json(Helper::formatStandardApiResponse('error', null, $user->getErrors()));
615+
return response()->json(Helper::formatStandardApiResponse('success', (new UsersTransformer)->transformUser($user), trans('admin/users/message.success.update')));
616+
}
617+
return response()->json(Helper::formatStandardApiResponse('error', null, $user->getErrors()));
612618
}
613619

614620
/**

resources/lang/en-US/general.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@
644644
'use_cloned_image' => 'Clone image from original',
645645
'use_cloned_image_help' => 'You may clone the original image or you can upload a new one using the upload field below.',
646646
'use_cloned_no_image_help' => 'This item does not have an associated image and instead inherits from the model or category it belongs to. If you would like to use a specific image for this item, you can upload a new one below.',
647-
'footer_credit' => '<a target="_blank" href="https://snipeitapp.com" rel="noopener">Snipe-IT</a> is open source software, made with <i class="fa fa-heart" aria-hidden="true" style="color: #a94442; font-size: 10px" /></i><span class="sr-only">love</span> by <a href="https://bsky.app/profile/snipeitapp.com" rel="noopener">@snipeitapp.com</a>.',
647+
'footer_credit' => '<a target="_blank" href="https://snipeitapp.com" rel="noopener">Snipe-IT</a> is open source software, made with <i class="fa fa-heart" aria-hidden="true" style="color: #a94442; font-size: 10px" /></i><span class="sr-only">love</span> by Grokability, Inc.',
648648
'set_password' => 'Set a Password',
649649
'upload_deleted' => 'Upload Deleted',
650650
'child_locations' => 'Child Locations',

resources/views/account/view-assets.blade.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
@can('self.profile')
147147
@if (Auth::user()->ldap_import!='1')
148148
<div class="col-md-12" style="padding-top: 5px;">
149-
<a href="{{ route('account.password.index') }}" style="width: 100%;" class="btn btn-sm btn-primary btn-social btn-block hidden-print" rel="noopener">
149+
<a href="{{ route('account.password.index') }}" style="width: 100%;" class="btn btn-sm btn-theme btn-social btn-block hidden-print" rel="noopener">
150150
<x-icon type="password" class="fa-fw" />
151151
{{ trans('general.changepassword') }}
152152
</a>
@@ -156,7 +156,7 @@
156156

157157
@can('self.api')
158158
<div class="col-md-12" style="padding-top: 5px;">
159-
<a href="{{ route('user.api') }}" style="width: 100%;" class="btn btn-sm btn-primary btn-social btn-block hidden-print" rel="noopener">
159+
<a href="{{ route('user.api') }}" style="width: 100%;" class="btn btn-sm btn-theme btn-social btn-block hidden-print" rel="noopener">
160160
<x-icon type="api-key" class="fa-fw" />
161161
{{ trans('general.manage_api_keys') }}
162162
</a>
@@ -165,7 +165,7 @@
165165

166166

167167
<div class="col-md-12" style="padding-top: 5px;">
168-
<a href="{{ route('profile.print') }}" style="width: 100%;" class="btn btn-sm btn-primary btn-social btn-block hidden-print" target="_blank" rel="noopener">
168+
<a href="{{ route('profile.print') }}" style="width: 100%;" class="btn btn-sm btn-theme btn-social btn-block hidden-print" target="_blank" rel="noopener">
169169
<x-icon type="print" class="fa-fw" />
170170
{{ trans('admin/users/general.print_assigned') }}
171171
</a>
@@ -176,13 +176,13 @@
176176
@if (!empty($user->email))
177177
<form action="{{ route('profile.email_assets') }}" method="POST">
178178
{{ csrf_field() }}
179-
<button style="width: 100%;" class="btn btn-sm btn-primary btn-social btn-block hidden-print" rel="noopener">
179+
<button style="width: 100%;" class="btn btn-sm btn-theme btn-social btn-block hidden-print" rel="noopener">
180180
<x-icon type="email" class="fa-fw" />
181181
{{ trans('admin/users/general.email_assigned') }}
182182
</button>
183183
</form>
184184
@else
185-
<button style="width: 100%;" class="btn btn-sm btn-primary btn-social btn-block hidden-print disabled" rel="noopener" disabled title="{{ trans('admin/users/message.user_has_no_email') }}">
185+
<button style="width: 100%;" class="btn btn-sm btn-theme btn-social btn-block hidden-print disabled" rel="noopener" disabled title="{{ trans('admin/users/message.user_has_no_email') }}">
186186
<x-icon type="email" class="fa-fw" />
187187
{{ trans('admin/users/general.email_assigned') }}
188188
</button>
@@ -692,7 +692,7 @@ class="table table-striped snipe-table table-hover"
692692
@endcan
693693
<td class="hidden-print">
694694
@can('checkin', $accessory)
695-
<a href="{{ route('accessories.checkin.show', array('accessoryID'=> $accessory->pivot->id, 'backto'=>'user')) }}" class="btn btn-primary btn-sm hidden-print">{{ trans('general.checkin') }}</a>
695+
<a href="{{ route('accessories.checkin.show', array('accessoryID'=> $accessory->pivot->id, 'backto'=>'user')) }}" class="btn btn-theme btn-sm hidden-print">{{ trans('general.checkin') }}</a>
696696
@endcan
697697
</td>
698698
</tr>

resources/views/dashboard.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class="table table-striped snipe-table"
257257
</div><!-- /.responsive -->
258258
</div><!-- /.col -->
259259
<div class="text-center col-md-12" style="padding-top: 10px;">
260-
<a href="{{ route('reports.activity') }}" class="btn btn-primary btn-sm" style="width: 100%">{{ trans('general.viewall') }}</a>
260+
<a href="{{ route('reports.activity') }}" class="btn btn-theme btn-sm" style="width: 100%">{{ trans('general.viewall') }}</a>
261261
</div>
262262
</div><!-- /.row -->
263263
</div><!-- ./box-body -->
@@ -355,7 +355,7 @@ class="table table-striped snipe-table"
355355
</div>
356356
</div> <!-- /.col -->
357357
<div class="text-center col-md-12" style="padding-top: 10px;">
358-
<a href="{{ route('companies.index') }}" class="btn btn-primary btn-sm" style="width: 100%">{{ trans('general.viewall') }}</a>
358+
<a href="{{ route('companies.index') }}" class="btn btn-theme btn-sm" style="width: 100%">{{ trans('general.viewall') }}</a>
359359
</div>
360360
</div> <!-- /.row -->
361361

@@ -414,7 +414,7 @@ class="table table-striped snipe-table"
414414
</div>
415415
</div> <!-- /.col -->
416416
<div class="text-center col-md-12" style="padding-top: 10px;">
417-
<a href="{{ route('locations.index') }}" class="btn btn-primary btn-sm" style="width: 100%">{{ trans('general.viewall') }}</a>
417+
<a href="{{ route('locations.index') }}" class="btn btn-theme btn-sm" style="width: 100%">{{ trans('general.viewall') }}</a>
418418
</div>
419419
</div> <!-- /.row -->
420420

@@ -485,7 +485,7 @@ class="table table-striped snipe-table"
485485
</div>
486486
</div> <!-- /.col -->
487487
<div class="text-center col-md-12" style="padding-top: 10px;">
488-
<a href="{{ route('categories.index') }}" class="btn btn-primary btn-sm" style="width: 100%">{{ trans('general.viewall') }}</a>
488+
<a href="{{ route('categories.index') }}" class="btn btn-theme btn-sm" style="width: 100%">{{ trans('general.viewall') }}</a>
489489
</div>
490490
</div> <!-- /.row -->
491491

resources/views/layouts/default.blade.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
--nav-hover-text-color: {{ $nav_link_color ?? 'light-dark(hsl(from var(--main-theme-color) h s calc(l - 10)),hsl(from var(--main-theme-color) h s calc(l - 10)))' }};
6262
--main-footer-bg-color: light-dark(#ffffff,#3d4144);
6363
--main-footer-top-border-color: light-dark(#d2d6de,#605e5e);
64-
--main-footer-text-color: light-dark(##605e5e, #d2d6de);
64+
--main-footer-text-color: light-dark(#605e5e, #d2d6de);
6565
6666
}
6767
@@ -149,6 +149,11 @@
149149
color: var(--link-hover) !important;
150150
}
151151
152+
153+
.footer-links a {
154+
color: light-dark(hsl(from var(--link-color) h s calc(l + 10)),hsl(from var(--link-color) h s calc(l - 32))) !important;
155+
}
156+
152157
h2 small {
153158
color: var(--color-fg) !important;
154159
}
@@ -1695,11 +1700,25 @@
16951700
<div class="hidden-xs pull-left">
16961701
<div class="pull-left footer-links">
16971702
{!! trans('general.footer_credit') !!}
1703+
1704+
<a target="_blank" href="https://bsky.app/profile/snipeitapp.com" rel="noopener" data-tooltip="true" data-title="Join us on Bluesky">
1705+
<i class="fa-brands fa-square-bluesky"></i>
1706+
</a>
1707+
<a target="_blank" href="https://hachyderm.io/@grokability" rel="noopener" data-tooltip="true" data-title="Join us on Github">
1708+
<i class="fa-brands fa-square-github"></i>
1709+
</a>
1710+
<a target="_blank" href="https://hachyderm.io/@grokability" rel="noopener" data-tooltip="true" data-title="Join us on Mastodon">
1711+
<i class="fa-brands fa-mastodon"></i>
1712+
</a>
1713+
<a target="_blank" href="https://discord.gg/yZFtShAcKk" rel="noopener" data-tooltip="true" data-title="Join us on Discord">
1714+
<i class="fa-brands fa-discord"></i>
1715+
</a>
1716+
16981717
</div>
16991718
<div class="pull-right">
17001719
@if ($snipeSettings->version_footer!='off')
17011720
@if (($snipeSettings->version_footer=='on') || (($snipeSettings->version_footer=='admin') && (Auth::user()->isSuperUser()=='1')))
1702-
&nbsp; <strong>{{ trans('general.version') }}</strong> {{ config('version.app_version') }} -
1721+
&nbsp; {{ trans('general.version') }} {{ config('version.app_version') }} -
17031722
{{ trans('general.build') }} {{ config('version.build_version') }} ({{ config('version.branch') }})
17041723
@endif
17051724
@endif

0 commit comments

Comments
 (0)