diff options
Diffstat (limited to 'app/class/user.class.php')
-rw-r--r-- | app/class/user.class.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/app/class/user.class.php b/app/class/user.class.php index b0b3435..9892277 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -205,6 +205,51 @@ class user extends agent { return hash("sha256", $passwd . $salt); } + + /* + * Validate the given plain-text password for this user. Returns true if + * correct, false otherwise. + */ + public function validatePasswd(string $passwd) : bool + { + $auth = self::getAuth($passwd, $this->salt); + return $auth == $this->auth; + } + + /* + * Update the auth and salt for this user, given a new plain-text + * password. + */ + public function setPasswd(string $passwd) : void + { + $this->salt = self::getBlob(); + $this->auth = self::getAuth($passwd, $this->salt); + } + + /* + * Validate the email confirmation code for this user. Returns true if + * correct, false otherwise. On success, $this->emailConf is also set + * to 1 + */ + public function verifyEmail(string $ver) : bool + { + if ($ver != $this->emailVer) + return false; + + $this->emailConf = 1; + return true; + } + + /* + * Update the email address for this user. This function will automatically + * reset the emailConf flag and confirmation code for this user as well. + */ + public function setEmail(string $email) : void + { + $this->email = $email; + $this->emailVer = substr(self::getBlob(), 0, 8); + $this->emailConf = 0; + } } ?> |