38 lines
946 B
PHP
38 lines
946 B
PHP
<?php
|
|
namespace Hanyuu\Users;
|
|
|
|
use Index\DateTime;
|
|
use Index\Data\IDbResult;
|
|
|
|
class UserPasswordInfo {
|
|
private string $userId;
|
|
private string $hash;
|
|
private DateTime $changed;
|
|
|
|
public function __construct(IDbResult $result) {
|
|
$this->userId = $result->getString(0);
|
|
$this->hash = $result->getString(1);
|
|
$this->changed = DateTime::fromUnixTimeSeconds($result->getInteger(2));
|
|
}
|
|
|
|
public function getUserId(): string {
|
|
return $this->userId;
|
|
}
|
|
|
|
public function getHash(): string {
|
|
return $this->hash;
|
|
}
|
|
|
|
public function getChangedTime(): DateTime {
|
|
return $this->changed;
|
|
}
|
|
|
|
public function verifyPassword(string $password): bool {
|
|
return password_verify($password, $this->hash);
|
|
}
|
|
|
|
public function needsRehash(string|int|null $algo, array $options = []): bool {
|
|
return password_needs_rehash($this->hash, $algo, $options);
|
|
}
|
|
}
|