Return stock of cancelled maintenance, throttle the PIN page's password
Cancelling a maintenance record now reverses the stock it used, through Inventory's new ReverseMaintenanceStockUse behind the MaintenanceMaterials port, in the same transaction as the cancellation. The PIN page allows 5 wrong current passwords a minute per user, as the login form does, so a signed-in session cannot be used to guess the password. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -131,6 +131,12 @@ it('shows a maintenance request when due and resets the interval with a maintena
|
||||
->call('cancelRecord')
|
||||
->assertSee('Peruttu')
|
||||
->assertSee('Huolto myöhässä');
|
||||
|
||||
$reversal = StockMovementModel::query()->where('reverses_movement_id', $use->id)->sole();
|
||||
|
||||
expect($reversal->quantity_milli)->toBe(1_000)
|
||||
->and($reversal->user_id)->toBe($this->manager->id)
|
||||
->and((int) StockMovementModel::query()->where('stock_item_id', $this->drum->id)->sum('quantity_milli'))->toBe(0);
|
||||
});
|
||||
|
||||
it('notifies the responsible person of a maintenance request once', function () {
|
||||
|
||||
@@ -53,6 +53,29 @@ it('removes the PIN code with the user\'s password', function () {
|
||||
expect($this->user->fresh()->pin_hash)->toBeNull();
|
||||
});
|
||||
|
||||
it('stops checking the password after 5 wrong ones a minute', function () {
|
||||
$component = Livewire::test('users::pin');
|
||||
|
||||
foreach (range(1, 5) as $attempt) {
|
||||
$component->set('currentPassword', 'väärä')->call('remove')->assertHasErrors(['currentPassword' => __('users.pin.errors.password')]);
|
||||
}
|
||||
|
||||
$this->user->forceFill(['pin_hash' => Hash::make('2468')])->save();
|
||||
|
||||
$component->set('currentPassword', 'Salasana-123!')
|
||||
->call('remove')
|
||||
->assertHasErrors('currentPassword')
|
||||
->assertSet('message', '');
|
||||
|
||||
expect($this->user->fresh()->pin_hash)->not->toBeNull();
|
||||
|
||||
$this->travel(61)->seconds();
|
||||
|
||||
$component->set('currentPassword', 'Salasana-123!')
|
||||
->call('remove')
|
||||
->assertSet('message', __('users.pin.removed'));
|
||||
});
|
||||
|
||||
it('is not offered to subcontractors', function () {
|
||||
$this->actingAs(User::factory()->subcontractor()->create());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user