31 lines
1.1 KiB
PHP
31 lines
1.1 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
namespace Modules\Core\Privacy;
|
||
|
|
|
||
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||
|
|
use Lunar\Base\LunarUser;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Identifies "the person" for a User-scoped data-subject request — erasing/
|
||
|
|
* exporting one individual's own identity (login, name, email) wherever it
|
||
|
|
* appears, regardless of how many Customer (business) accounts they're linked to.
|
||
|
|
* Deliberately carries no customerId: a provider that needs to know which
|
||
|
|
* Customer accounts this User is linked to (e.g. to detach them, or to find data
|
||
|
|
* keyed by a shared email) looks that up itself, rather than this value object
|
||
|
|
* assuming one fixed Customer — the whole point is that one User can belong to
|
||
|
|
* many Customer accounts (B2B multi-seat access) and erasing the User must not
|
||
|
|
* assume or privilege any single one of them.
|
||
|
|
*/
|
||
|
|
class UserSubject
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
public readonly int $userId,
|
||
|
|
public readonly ?string $email = null,
|
||
|
|
) {}
|
||
|
|
|
||
|
|
public static function forUser(Authenticatable&LunarUser $user): self
|
||
|
|
{
|
||
|
|
return new self(userId: $user->id, email: $user->email);
|
||
|
|
}
|
||
|
|
}
|