You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Pablo\Ae3auth\app\Observers;
|
|
|
|
use Pablo\Ae3auth\app\Facades\PasswordHistoryManager;
|
|
use Pablo\Ae3auth\app\Services\PasswordHistoryService;
|
|
|
|
class UserObserver
|
|
{
|
|
public function __construct(
|
|
private readonly PasswordHistoryService $passwordHistoryService
|
|
)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* @param $user
|
|
* @return void
|
|
*/
|
|
public function updating($user): void
|
|
{
|
|
PasswordHistoryManager::logPassword($user);
|
|
$passwordCol = config('ae3auth-config.user.password_column');
|
|
if ($user->isDirty($passwordCol)) {
|
|
$this->passwordHistoryService->updateExpireColumn($user);
|
|
$this->passwordHistoryService->makePasswordAvailable($user);
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* @param $user
|
|
* @return void
|
|
*/
|
|
public function created($user): void
|
|
{
|
|
PasswordHistoryManager::logNewPassword($user->id, $user->password);
|
|
}
|
|
|
|
/**
|
|
* @param $user
|
|
* @return void
|
|
*/
|
|
public function creating($user): void
|
|
{
|
|
$this->passwordHistoryService->updateExpireColumn($user);
|
|
}
|
|
}
|