mirror of
https://github.com/pierre42100/ComunicAPI
synced 2025-06-19 08:35:18 +00:00
Can update user password
This commit is contained in:
@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user