|
|
|
@ -20,7 +20,7 @@ class PasswordHistoryService implements Contracts\PasswordHistoryServiceContract
|
|
|
|
|
*/
|
|
|
|
|
public function inHistory(int|string $userId, string $password): bool
|
|
|
|
|
{
|
|
|
|
|
$passwords = $this->passwordHistoryRepository->passwords($userId);
|
|
|
|
|
$passwords = $this->passwordHistoryRepository->getPasswords($userId);
|
|
|
|
|
foreach ($passwords as $history) {
|
|
|
|
|
if (Hash::check($password, $history->password)) {
|
|
|
|
|
return false;
|
|
|
|
@ -36,8 +36,8 @@ class PasswordHistoryService implements Contracts\PasswordHistoryServiceContract
|
|
|
|
|
*/
|
|
|
|
|
public function logPassword($user): void
|
|
|
|
|
{
|
|
|
|
|
$passwords = $this->passwordHistoryRepository->passwords($user->id);
|
|
|
|
|
if (count($passwords) >= config('ae3auth-config.max_stored_passwords')) {
|
|
|
|
|
$countPasswords = $this->passwordHistoryRepository->countPasswords($user->id);
|
|
|
|
|
if ($countPasswords >= config('ae3auth-config.max_stored_passwords')) {
|
|
|
|
|
$this->removeOldestPassword($user->id);
|
|
|
|
|
}
|
|
|
|
|
$passwordCol = config('ae3auth-config.user.password_column');
|
|
|
|
@ -60,9 +60,28 @@ class PasswordHistoryService implements Contracts\PasswordHistoryServiceContract
|
|
|
|
|
*/
|
|
|
|
|
public function removeOldestPassword($userId): void
|
|
|
|
|
{
|
|
|
|
|
$oldest = $this->passwordHistoryRepository->oldestPassword($userId);
|
|
|
|
|
$oldest = $this->passwordHistoryRepository->findOldestPassword($userId);
|
|
|
|
|
if ($oldest) {
|
|
|
|
|
$this->passwordHistoryRepository->destroy($oldest->id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $user
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function updateExpireColumn($user): void
|
|
|
|
|
{
|
|
|
|
|
$expiresAtColumn = config('ae3auth-config.user.expires_password_column_name');
|
|
|
|
|
$user->$expiresAtColumn = now()->addDays(config('ae3auth-config.password_expires_in'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function makePasswordAvailable($user): void
|
|
|
|
|
{
|
|
|
|
|
$forceChangePasswordColumn = config('ae3auth-config.user.force_change_column_name');
|
|
|
|
|
$user->$forceChangePasswordColumn = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|