PFUser *user = [PFUser currentUser];
// I can see the details of the users when this is called including password
if (user) {
if ([_login_txtpassword.text isEqualToString:user[@"UserPasswrod"]]) {
user[@"userPassword"] = _login_txtnewpassword.text;
[user saveInBackground];
NSLog(@"done");
}
}
this code is not working.... i have put blocks to test my code ... it doesnt pass the if statement
A little conflict in my concepts related parse (so consider me as a noob) P.S i have read the documentation and search internet but couldnt find a solution.
Many Many thanks in advcance
The right way to do this is to try to log the user in with the old password, then set the new password if successful. (notice this code uses the parse User password
attribute, not @"userPassword"
as in the OP code, which won't work under any circumstances)...
NSString *username = [PFUser currentUser].username;
NSString *oldPassword = self.oldPasswordTextField.text;
NSString *newPassword = self.newPasswordTextField.text;
[PFUser logInWithUsernameInBackground:username password:oldPassword
block:^(PFUser *user, NSError *error) {
if (user) {
user.password = newPassword;
[user saveInBackground];
} else {
// update UI to tell user that the old password is incorrect
}
}];