Resets the current user password with a new password and updates it in the database. This method hashes the provided password and sets it as the new password for the user. # Errors when has DB query error or could not hashed the given password
(
mut self,
db: &DatabaseConnection,
password: &str,
)
| 256 | /// |
| 257 | /// when has DB query error or could not hashed the given password |
| 258 | pub async fn reset_password( |
| 259 | mut self, |
| 260 | db: &DatabaseConnection, |
| 261 | password: &str, |
| 262 | ) -> ModelResult<Model> { |
| 263 | self.password = |
| 264 | ActiveValue::set(hash::hash_password(password).map_err(|e| ModelError::Any(e.into()))?); |
| 265 | Ok(self.update(db).await?) |
| 266 | } |
| 267 | } |