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.
33 lines
741 B
PHP
33 lines
741 B
PHP
<?php
|
|
|
|
namespace Pablo\Ae3auth\app\Observers;
|
|
|
|
use Pablo\Ae3auth\app\Facades\PasswordHistoryManager;
|
|
|
|
class UserObserver
|
|
{
|
|
/**
|
|
* @param $user
|
|
* @return void
|
|
*/
|
|
public function updating($user): void
|
|
{
|
|
PasswordHistoryManager::logPassword($user);
|
|
$user->update([
|
|
'password_expires_at' => now()->addDays(config('ae3auth-config.password_expires_in'))
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @param $user
|
|
* @return void
|
|
*/
|
|
public function created($user): void
|
|
{
|
|
PasswordHistoryManager::logNewPassword($user->id, $user->password);
|
|
$user->update([
|
|
'password_expires_at' => now()->addDays(config('ae3auth-config.password_expires_in'))
|
|
]);
|
|
}
|
|
}
|