Feat: Recording Legal Acceptance
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\Auth\Listeners;
|
||||
|
||||
use Modules\Core\Auth\Events\UserCreated;
|
||||
|
||||
/**
|
||||
* The storefront login page shows a terms/privacy notice ("By continuing,
|
||||
* you accept the Terms of Use and have read the Privacy Policy") that
|
||||
* requesting an OTP code implicitly accepts — recorded once, right here,
|
||||
* for a genuinely new signup only (UserCreated fires exactly once per
|
||||
* user, from Auth\Services\UserOtpService::generateAndSend()'s own
|
||||
* wasRecentlyCreated check). An existing user's original acceptance
|
||||
* (whatever version was live when THEY signed up) must never be
|
||||
* overwritten by whatever config('legal.*') says today, which is exactly
|
||||
* why this only ever runs from UserCreated and nowhere else.
|
||||
*/
|
||||
class RecordLegalAcceptanceForNewUser
|
||||
{
|
||||
public function handle(UserCreated $event): void
|
||||
{
|
||||
$event->user->forceFill([
|
||||
'terms_accepted_at' => now(),
|
||||
'terms_version' => config('legal.terms_version'),
|
||||
'privacy_policy_version' => config('legal.privacy_policy_version'),
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user