A free open source IT asset/license management system
Store the sign in place in the session so it’s remembered
snipe18f67bcce529
diff --git a/app/Http/Controllers/Assets/AssetCheckoutController.php b/app/Http/Controllers/Assets/AssetCheckoutController.phpindex 23289e32a0..f11257fc24 100644--- a/app/Http/Controllers/Assets/AssetCheckoutController.php+++ b/app/Http/Controllers/Assets/AssetCheckoutController.php@@ -124,7 +124,11 @@ class AssetCheckoutController extends Controller}}- session()->put(['redirect_option' => $request->input('redirect_option'), 'checkout_to_type' => $request->input('checkout_to_type')]);+ session()->put([+ 'redirect_option' => $request->input('redirect_option'),+ 'checkout_to_type' => $request->input('checkout_to_type'),+ 'sign_in_place' => $request->boolean('sign_in_place'),+ ]);if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, $request->input('note'), $request->input('name'))) {diff --git a/app/Http/Controllers/Consumables/ConsumableCheckoutController.php b/app/Http/Controllers/Consumables/ConsumableCheckoutController.phpindex 81fbd22749..39961acbc1 100644--- a/app/Http/Controllers/Consumables/ConsumableCheckoutController.php+++ b/app/Http/Controllers/Consumables/ConsumableCheckoutController.php@@ -122,7 +122,11 @@ class ConsumableCheckoutController extends Controller$request->request->add(['checkout_to_type' => 'user']);$request->request->add(['assigned_user' => $user->id]);- session()->put(['redirect_option' => $request->input('redirect_option'), 'checkout_to_type' => $request->input('checkout_to_type')]);+ session()->put([+ 'redirect_option' => $request->input('redirect_option'),+ 'checkout_to_type' => $request->input('checkout_to_type'),+ 'sign_in_place' => $request->boolean('sign_in_place'),+ ]);// When sign_in_place is requested, redirect to the acceptance/signature page// so the user can sign in person. The signature is attributed to the target user.diff --git a/app/Http/Controllers/Licenses/LicenseCheckoutController.php b/app/Http/Controllers/Licenses/LicenseCheckoutController.phpindex 1fa5620143..884675e3c5 100644--- a/app/Http/Controllers/Licenses/LicenseCheckoutController.php+++ b/app/Http/Controllers/Licenses/LicenseCheckoutController.php@@ -102,13 +102,21 @@ class LicenseCheckoutController extends Controllersession()->put(['checkout_to_type' => 'asset']);$checkoutTarget = $this->checkoutToAsset($licenseSeat);$request->request->add(['assigned_asset' => $checkoutTarget->id]);- session()->put(['redirect_option' => $request->input('redirect_option'), 'checkout_to_type' => 'asset']);+ session()->put([+ 'redirect_option' => $request->input('redirect_option'),+ 'checkout_to_type' => 'asset',+ 'sign_in_place' => $request->boolean('sign_in_place'),+ ]);} elseif ($request->filled('assigned_to')) {session()->put(['checkout_to_type' => 'user']);$checkoutTarget = $this->checkoutToUser($licenseSeat);$request->request->add(['assigned_user' => $checkoutTarget->id]);- session()->put(['redirect_option' => $request->input('redirect_option'), 'checkout_to_type' => 'user']);+ session()->put([+ 'redirect_option' => $request->input('redirect_option'),+ 'checkout_to_type' => 'user',+ 'sign_in_place' => $request->boolean('sign_in_place'),+ ]);}if ($checkoutTarget) {diff --git a/resources/views/consumables/checkout.blade.php b/resources/views/consumables/checkout.blade.phpindex 7f2ac524e6..aba7bbad57 100644--- a/resources/views/consumables/checkout.blade.php+++ b/resources/views/consumables/checkout.blade.php@@ -116,7 +116,7 @@<div class="form-group" id="sign_in_place_div"><div class="col-md-7 col-md-offset-3"><label class="form-control">- <input type="checkbox" value="1" name="sign_in_place" @checked(old('sign_in_place')) aria-label="sign_in_place">+ <input type="checkbox" value="1" name="sign_in_place" @checked(old('sign_in_place', session('sign_in_place', false))) aria-label="sign_in_place">{{ trans('general.sign_in_place') }}</label><p class="help-block">diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.phpindex 0f72943a09..f4a7265d44 100755--- a/resources/views/hardware/checkout.blade.php+++ b/resources/views/hardware/checkout.blade.php@@ -201,7 +201,7 @@<div class="form-group" id="sign_in_place_div"><div class="col-md-7 col-md-offset-3"><label class="form-control">- <input type="checkbox" value="1" name="sign_in_place" @checked(old('sign_in_place')) aria-label="sign_in_place">+ <input type="checkbox" value="1" name="sign_in_place" @checked(old('sign_in_place', session('sign_in_place', false))) aria-label="sign_in_place">{{ trans('general.sign_in_place') }}</label><p class="help-block">diff --git a/resources/views/licenses/checkout.blade.php b/resources/views/licenses/checkout.blade.phpindex a5f70d6931..492ab3a171 100755--- a/resources/views/licenses/checkout.blade.php+++ b/resources/views/licenses/checkout.blade.php@@ -120,7 +120,7 @@<div class="form-group" id="sign_in_place_div"><div class="col-md-7 col-md-offset-3"><label class="form-control">- <input type="checkbox" value="1" name="sign_in_place" @checked(old('sign_in_place')) aria-label="sign_in_place">+ <input type="checkbox" value="1" name="sign_in_place" @checked(old('sign_in_place', session('sign_in_place', false))) aria-label="sign_in_place">{{ trans('general.sign_in_place') }}</label><p class="help-block">diff --git a/tests/Feature/Checkouts/Ui/AssetCheckoutTest.php b/tests/Feature/Checkouts/Ui/AssetCheckoutTest.phpindex 315ceb1886..c776e9f4a7 100644--- a/tests/Feature/Checkouts/Ui/AssetCheckoutTest.php+++ b/tests/Feature/Checkouts/Ui/AssetCheckoutTest.php@@ -377,4 +377,20 @@ class AssetCheckoutTest extends TestCase$response->assertStatus(302)->assertRedirect(route('account.accept.item', $acceptance));}++ public function test_asset_checkout_stores_sign_in_place_preference_in_session()+ {+ $targetUser = User::factory()->create();+ $asset = Asset::factory()->create();++ $response = $this->actingAs(User::factory()->admin()->create())+ ->post(route('hardware.checkout.store', $asset), [+ 'checkout_to_type' => 'user',+ 'assigned_user' => $targetUser->id,+ 'redirect_option' => 'index',+ 'sign_in_place' => 1,+ ]);++ $response->assertSessionHas('sign_in_place', true);+ }}diff --git a/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php b/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.phpindex 99f73abc32..e403adc12e 100644--- a/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php+++ b/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php@@ -202,4 +202,20 @@ class ConsumableCheckoutTest extends TestCase$response->assertStatus(302)->assertRedirect(route('account.accept.item', $acceptance));}++ public function test_consumable_checkout_stores_sign_in_place_preference_in_session()+ {+ $targetUser = User::factory()->create();+ $consumable = Consumable::factory()->create();++ $response = $this->actingAs(User::factory()->admin()->create())+ ->post(route('consumables.checkout.store', $consumable), [+ 'assigned_to' => $targetUser->id,+ 'redirect_option' => 'index',+ 'checkout_qty' => 1,+ 'sign_in_place' => 1,+ ]);++ $response->assertSessionHas('sign_in_place', true);+ }}diff --git a/tests/Feature/Checkouts/Ui/LicenseCheckoutTest.php b/tests/Feature/Checkouts/Ui/LicenseCheckoutTest.phpindex fb24d065ff..bec80d2a27 100644--- a/tests/Feature/Checkouts/Ui/LicenseCheckoutTest.php+++ b/tests/Feature/Checkouts/Ui/LicenseCheckoutTest.php@@ -151,4 +151,19 @@ class LicenseCheckoutTest extends TestCase$response->assertStatus(302)->assertRedirect(route('account.accept.item', $acceptance));}++ public function test_license_checkout_stores_sign_in_place_preference_in_session()+ {+ $targetUser = User::factory()->create();+ $seat = LicenseSeat::factory()->create();++ $response = $this->actingAs(User::factory()->admin()->create())+ ->post(route('licenses.checkout', $seat->license), [+ 'assigned_to' => $targetUser->id,+ 'redirect_option' => 'index',+ 'sign_in_place' => 1,+ ]);++ $response->assertSessionHas('sign_in_place', true);+ }}