Can update user password

This commit is contained in:
Pierre
2018-04-20 10:17:52 +02:00
parent 8909043413
commit 19292b70b0
2 changed files with 43 additions and 0 deletions

View File

@ -157,6 +157,30 @@ class SettingsController {
return array("success" => "The security settings of the user have been successfully saved !");
}
/**
* Update user password
*
* @url POST /settings/update_password
*/
public function updatePassword(){
//User login required
user_login_required();
//Check the old password
check_post_password(userID, "oldPassword");
//Get and save the new password
$newPassword = postString("newPassword");
//Try to save password
if(!components()->account->set_new_user_password(userID, $newPassword))
Rest_fatal_error(500, "Could not update user password!");
//Success
return array("success" => "The password has been updated !");
}
/**
* Turn a GeneralSettings object into a valid API object
*