Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8a8e1cc09 | ||
|
|
522dc1db2a | ||
|
|
db907815ff | ||
|
|
ae6abdddad | ||
|
|
63c9fbe10c | ||
|
|
101dfd01f2 | ||
|
|
5db5134ae0 | ||
|
|
5294489b0e | ||
|
|
05b2b8fb59 | ||
|
|
0100c56046 | ||
|
|
e81b221fd1 | ||
|
|
f374ac1bf7 | ||
|
|
524c6c502e | ||
|
|
614e858e44 | ||
|
|
708b1a962c |
@@ -7,7 +7,6 @@ APP_KEY=ChangeMe
|
||||
APP_URL=null
|
||||
APP_TIMEZONE='UTC'
|
||||
APP_LOCALE=en
|
||||
BACKUP_ENV=false
|
||||
|
||||
# --------------------------------------------
|
||||
# REQUIRED: DATABASE SETTINGS
|
||||
|
||||
@@ -79,6 +79,7 @@ class PaveIt extends Command
|
||||
DB::statement('delete from accessories_users');
|
||||
DB::statement('delete from asset_logs');
|
||||
DB::statement('delete from asset_maintenances');
|
||||
DB::statement('delete from login_attempts');
|
||||
DB::statement('delete from asset_uploads');
|
||||
DB::statement('delete from action_logs');
|
||||
DB::statement('delete from checkout_requests');
|
||||
|
||||
120
app/Console/Commands/RestoreDeletedUsers.php
Normal file
120
app/Console/Commands/RestoreDeletedUsers.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\User;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\LicenseSeat;
|
||||
use App\Models\License;
|
||||
use DB;
|
||||
use Artisan;
|
||||
|
||||
class RestoreDeletedUsers extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'snipeit:restore-users {--start_date=} {--end_date=}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Restore users, and any associated assets and license checkouts.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$start_date = $this->option('start_date');
|
||||
$end_date = $this->option('end_date');
|
||||
$asset_totals = 0;
|
||||
$license_totals = 0;
|
||||
$user_count = 0;
|
||||
|
||||
|
||||
if (($start_date=='') || ($end_date=='')) {
|
||||
$this->info('ERROR: All fields are required.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$users = User::whereBetween('deleted_at', [$start_date, $end_date])->withTrashed()->get();
|
||||
$this->info('There are '.$users->count().' users deleted between '.$start_date.' and '.$end_date);
|
||||
$this->warn('Making a backup!');
|
||||
Artisan::call('backup:run');
|
||||
|
||||
foreach ($users as $user) {
|
||||
$user_count++;
|
||||
$user_logs = Actionlog::where('target_id', $user->id)->where('target_type',User::class)
|
||||
->where('action_type','checkout')->with('item')->get();
|
||||
|
||||
$this->info($user_count.'. '.$user->username.' ('.$user->id.') was deleted at '.$user->deleted_at. ' and has '.$user_logs->count().' checkouts associated.');
|
||||
|
||||
foreach ($user_logs as $user_log) {
|
||||
$this->info(' * '.$user_log->item_type.': '.$user_log->item->name.' - item_id: '.$user_log->item_id);
|
||||
|
||||
if ($user_log->item_type==Asset::class) {
|
||||
$asset_totals++;
|
||||
|
||||
DB::table('assets')
|
||||
->where('id', $user_log->item_id)
|
||||
->update(['assigned_to' => $user->id, 'assigned_type'=> User::class]);
|
||||
|
||||
$this->info(' ** Asset '.$user_log->item->id.' ('.$user_log->item->asset_tag.') restored to user '.$user->id.'');
|
||||
|
||||
} elseif ($user_log->item_type==License::class) {
|
||||
$license_totals++;
|
||||
|
||||
$avail_seat = DB::table('license_seats')->where('license_id','=',$user_log->item->id)
|
||||
->whereNull('assigned_to')->whereNull('asset_id')->whereBetween('updated_at', [$start_date, $end_date])->first();
|
||||
if ($avail_seat) {
|
||||
$this->info(' ** Allocating seat '.$avail_seat->id.' for this License');
|
||||
|
||||
DB::table('license_seats')
|
||||
->where('id', $avail_seat->id)
|
||||
->update(['assigned_to' => $user->id]);
|
||||
|
||||
} else {
|
||||
$this->warn('ERROR: No available seats for '.$user_log->item->name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->warn('Restoring user '.$user->username.'!');
|
||||
$user->restore();
|
||||
|
||||
|
||||
}
|
||||
|
||||
$this->info($asset_totals.' assets affected');
|
||||
$this->info($license_totals.' licenses affected');
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -30,6 +30,7 @@ class Kernel extends ConsoleKernel
|
||||
Commands\SyncAssetLocations::class,
|
||||
Commands\RegenerateAssetTags::class,
|
||||
Commands\SyncAssetCounters::class,
|
||||
Commands\RestoreDeletedUsers::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -292,7 +292,7 @@ class UsersController extends Controller
|
||||
{
|
||||
$this->authorize('view', User::class);
|
||||
$this->authorize('view', Asset::class);
|
||||
$assets = Asset::where('assigned_to', '=', $id)->with('model')->get();
|
||||
$assets = Asset::where('assigned_to', '=', $id)->where('assigned_type', '=', User::class)->with('model')->get();
|
||||
return (new AssetsTransformer)->transformAssets($assets, $assets->count());
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,10 @@ class ForgotPasswordController extends Controller
|
||||
// to send the link, we will examine the response then see the message we
|
||||
// need to show to the user. Finally, we'll send out a proper response.
|
||||
$response = $this->broker()->sendResetLink(
|
||||
$request->only('email')
|
||||
array_merge(
|
||||
$request->only('email'),
|
||||
['activated' => '1']
|
||||
)
|
||||
);
|
||||
|
||||
if ($response === \Password::RESET_LINK_SENT) {
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
@@ -36,4 +38,8 @@ class ResetPasswordController extends Controller
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -86,8 +86,11 @@ class UsersController extends Controller
|
||||
$userPermissions = Helper::selectedPermissionsArray($permissions, Input::old('permissions', array()));
|
||||
$permissions = $this->filterDisplayable($permissions);
|
||||
|
||||
$user = new User;
|
||||
$user->activated = 1;
|
||||
|
||||
return view('users/edit', compact('groups', 'userGroups', 'permissions', 'userPermissions'))
|
||||
->with('user', new User);
|
||||
->with('user', $user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,7 +68,9 @@ class UserImporter extends ItemImporter
|
||||
'last_name' => $user->last_name,
|
||||
'password' => $this->tempPassword,
|
||||
];
|
||||
$user->notify(new WelcomeNotification($data));
|
||||
|
||||
// UNCOMMENT this to re-enable sending email notifications on user import
|
||||
// $user->notify(new WelcomeNotification($data));
|
||||
}
|
||||
$user = null;
|
||||
$this->item = null;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "snipe/snipe-it",
|
||||
"description": "Open source asset management system built on Laravel.",
|
||||
"keywords": ["assets", "asset-management", "laravel"],
|
||||
"license": "AGPL-3",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"php": ">=5.6.4",
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
return array (
|
||||
'app_version' => 'v4.6.3',
|
||||
'full_app_version' => 'v4.6.3 - build 3866-g3de1de9dc',
|
||||
'build_version' => '3866',
|
||||
'app_version' => 'v4.6.4',
|
||||
'full_app_version' => 'v4.6.4 - build 3881-g522dc1db2',
|
||||
'build_version' => '3881',
|
||||
'prerelease_version' => '',
|
||||
'hash_version' => 'g3de1de9dc',
|
||||
'full_hash' => 'v4.6.2-19-g3de1de9dc',
|
||||
'hash_version' => 'g522dc1db2',
|
||||
'full_hash' => 'v4.6.4-3881-g522dc1db2',
|
||||
'branch' => 'master',
|
||||
);
|
||||
);
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
return [
|
||||
'sent' => 'Your password link has been sent!',
|
||||
'user' => 'That user does not exist or does not have an email address associated',
|
||||
'user' => 'No matching active user found with that email.',
|
||||
];
|
||||
|
||||
|
||||
@@ -33,13 +33,16 @@
|
||||
border-color: {{ $snipeSettings->header_color }};
|
||||
}
|
||||
|
||||
@if ($snipeSettings->custom_css)
|
||||
{{ $snipeSettings->show_custom_css() }}
|
||||
@endif
|
||||
</style>
|
||||
|
||||
@endif
|
||||
|
||||
@if (($snipeSettings) && ($snipeSettings->custom_css))
|
||||
<style>
|
||||
{!! $snipeSettings->show_custom_css() !!}
|
||||
</style>
|
||||
@endif
|
||||
|
||||
</head>
|
||||
|
||||
<body class="hold-transition login-page">
|
||||
@@ -55,7 +58,7 @@
|
||||
|
||||
|
||||
<div class="text-center" style="padding-top: 100px;">
|
||||
@if ($snipeSettings->privacy_policy_link!='')
|
||||
@if (($snipeSettings) && ($snipeSettings->privacy_policy_link!=''))
|
||||
<a target="_blank" rel="noopener" href="{{ $snipeSettings->privacy_policy_link }}" target="_new">{{ trans('admin/settings/general.privacy_policy') }}</a>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@@ -54,9 +54,7 @@
|
||||
}
|
||||
@endif
|
||||
|
||||
@if (($snipeSettings) && ($snipeSettings->custom_css!=''))
|
||||
{!! $snipeSettings->show_custom_css() !!}
|
||||
@endif
|
||||
|
||||
|
||||
@media (max-width: 400px) {
|
||||
.navbar-left {
|
||||
@@ -69,6 +67,12 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
@if (($snipeSettings) && ($snipeSettings->custom_css))
|
||||
<style>
|
||||
{!! $snipeSettings->show_custom_css() !!}
|
||||
</style>
|
||||
@endif
|
||||
|
||||
<script nonce="{{ csrf_token() }}">
|
||||
window.snipeit = {
|
||||
settings: {
|
||||
|
||||
@@ -335,7 +335,7 @@
|
||||
<p class="help-block">{{ trans('general.feature_disabled') }}</p>
|
||||
</div>
|
||||
@elseif ($user->id === Auth::user()->id)
|
||||
<div class="icheckbox disabled"" style="padding-left: 10px;">
|
||||
<div class="icheckbox disabled" style="padding-left: 10px;">
|
||||
{{ Form::checkbox('activated', '1', old('activated', $user->activated),['class' => 'minimal', 'disabled'=>'disabled']) }}
|
||||
{{ trans('admin/users/general.activated_help_text') }}
|
||||
<p class="help-block">{{ trans('admin/users/general.activated_disabled_help_text') }}</p>
|
||||
|
||||
Reference in New Issue
Block a user