diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2020-04-10 15:33:49 +0200 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2020-04-10 15:33:49 +0200 |
commit | 7503edafe206d9f16da4d12b6dea0458ca9c2432 (patch) | |
tree | 9cb2e207dac95d4ffe49e5ef1c06ebfaefa8053e /app/class/User.php | |
parent | def7a991b0112f906fccf802587e8bc6b19bae29 (diff) | |
parent | c63a0228333e18fe2b1b84c29ab70af82698bdab (diff) | |
download | wcms-7503edafe206d9f16da4d12b6dea0458ca9c2432.tar.gz wcms-7503edafe206d9f16da4d12b6dea0458ca9c2432.zip |
Merge branch 'implement-password'
Diffstat (limited to 'app/class/User.php')
-rw-r--r-- | app/class/User.php | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/app/class/User.php b/app/class/User.php index b735309..518b096 100644 --- a/app/class/User.php +++ b/app/class/User.php @@ -208,11 +208,21 @@ class User extends Item - - public function hashpassword() + /** + * Hash the password and set `$passwordhashed` to true. + * + * @return bool true in cas of success, otherwise false. + */ + public function hashpassword() : bool { - $this->password = password_hash($this->password, PASSWORD_DEFAULT); - $this->passwordhashed = true; + $hashedpassword = password_hash($this->password, PASSWORD_DEFAULT); + if (!empty($hashedpassword)) { + $this->password = $hashedpassword; + $this->passwordhashed = true; + return true; + } else { + return false; + } } public function validpassword() |