Letting User Update Password – Parse – Swift

I am trying the code below to let users update their password when a uibutton is clicked. However, ever when I enter the current password right, I get the “wrong current password” message. I guess the system does not compare the entered value with the current password right. Without the first if condition, I can update the password. But I want the user to enter current password for security reasons first. May anyone help?

@IBAction func updatePasswordBtn(sender: AnyObject) {

    var passwordCheckQuery = PFQuery(className: "_User")
    passwordCheckQuery.whereKey("username", equalTo: PFUser.currentUser()!.username!)
    var objects = passwordCheckQuery.findObjects()

    for object in objects! {

        if currentPassword.text == PFUser.currentUser()!.password {

            if newPassword.text == retypeNewPassword.text {

                var query6 = PFUser.query()

                query6!.whereKey("username", equalTo: PFUser.currentUser()!.username!)

                query6!.findObjectsInBackgroundWithBlock {

                    (objects: [AnyObject]?, error: NSError?) -> Void in

                    for object6 in objects! {

                        var ob6:PFObject = object6 as! PFObject

                        ob6["password"] = self.newPassword.text





              else {  println("passwords dont match")


        else {  println("wrong current password")



Source: ios

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.