update
This commit is contained in:
parent
edfb2da790
commit
abaa9f12c9
4 changed files with 114 additions and 105 deletions
|
@ -71,15 +71,13 @@ impl User {
|
|||
}
|
||||
|
||||
/// Change the password of a `User`
|
||||
pub async fn passwd(&mut self, old: &str, new: &str) -> Result<(), ()> {
|
||||
pub async fn passwd(self, old: &str, new: &str) -> Result<(), ()> {
|
||||
if self.verify_pw(old) {
|
||||
self.update(&json!(
|
||||
{
|
||||
"password": bcrypt::hash(new, bcrypt::DEFAULT_COST).unwrap()
|
||||
}
|
||||
))
|
||||
.await
|
||||
.map_err(|_| ())?;
|
||||
self.change()
|
||||
.password(bcrypt::hash(new, bcrypt::DEFAULT_COST).unwrap())
|
||||
.update()
|
||||
.await
|
||||
.map_err(|_| ())?;
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue