Give the machine console its own session with PIN sign-in, make counters cumulative
The console under console/ has its own session cookie and console guard (UseConsoleSession), so signing out or changing user there leaves the normal interface alone. Links open it in a new window through a one-time handoff key; a signed-out console asks for a PIN code or password on its own login page. Users set their 4-6 digit PIN on the profile's PIN page, and the console's change user dialog takes it on a keypad; five wrong PINs lock PIN sign-in for 15 minutes. Machine counters are cumulative: users record how much a job used and it is added to the latest reading. A maintenance record restarts the whole counter interval from the reading at the record. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Users\Domain\Contracts;
|
||||
|
||||
/**
|
||||
* The hashes of a user's password and console PIN code.
|
||||
*/
|
||||
interface LoginSecrets
|
||||
{
|
||||
public function passwordHashOf(int $userId): ?string;
|
||||
|
||||
public function pinHashOf(int $userId): ?string;
|
||||
|
||||
/**
|
||||
* Stores the hash of the user's PIN code, or removes it with null.
|
||||
*/
|
||||
public function storePinHash(int $userId, ?string $hash): void;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Users\Domain\Exceptions;
|
||||
|
||||
use App\Modules\Shared\Domain\Exceptions\DomainException;
|
||||
|
||||
final class InvalidLoginPin extends DomainException
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('The PIN code must be 4–6 digits.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Users\Domain\Exceptions;
|
||||
|
||||
use App\Modules\Shared\Domain\Exceptions\DomainException;
|
||||
|
||||
final class WrongPassword extends DomainException
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('The current password is not correct.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Users\Domain\ValueObjects;
|
||||
|
||||
use App\Modules\Users\Domain\Exceptions\InvalidLoginPin;
|
||||
|
||||
/**
|
||||
* A user's own PIN code for switching user on a machine console: 4–6
|
||||
* digits. It is never stored as such, only its hash.
|
||||
*/
|
||||
final readonly class LoginPin
|
||||
{
|
||||
public const int MIN_LENGTH = 4;
|
||||
|
||||
public const int MAX_LENGTH = 6;
|
||||
|
||||
public string $value;
|
||||
|
||||
public function __construct(string $value)
|
||||
{
|
||||
$value = trim($value);
|
||||
|
||||
if (preg_match('/^\d{'.self::MIN_LENGTH.','.self::MAX_LENGTH.'}$/', $value) !== 1) {
|
||||
throw new InvalidLoginPin;
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user