Start a new topic
Answered

Update Users table without authentication

Hi, 


In my app, I have a Forgot password functionality where user is requested to enter registered mobile number, SMS sent with code and then verified, then user will be required to enter the new password. Upon entering password and saving, I want the user row matching the username I have to be updated.


How can this be done?


Here is the code I am doing to get the username of the user after he entered his mobile number that matches the database and verifying it:


 

let q = KCSQuery(onField: "mobile", withExactMatchForValue: "\(self.userInstance.mobile!)")
                    let collection = KCSCollection.userCollection()
                    let store = KCSAppdataStore(collection: collection, options: nil)
                    
                    store.queryWithQuery(q, withCompletionBlock: { (objectsOrNil: [AnyObject]!, error: NSError!) -> Void in
                        
                        if(objectsOrNil.count == 0)
                        {
                            /*Error - Empty user list retreived*/
                            
                            
                        }else{
                            /*get username from objectsOrNil*/
                            let username = objectsOrNil[0].getValueForAttribute("username")
                            print("\(username!)")
                        
                        
                        }
                        
                    
                    }, withProgressBlock: nil)

 Thanks in advance for the support


Best Answer

Khalid,


I have few questions for you:


  • Is there an active user when this code is executed?
  • What error do you see?
  • Currently how are you sending the SMS?


In case there is no active user, the updation of the new password could be done through a custom endpoint which would take the necessary parameters. If there is an active user, this code looks good to me.


Thanks,

Pranav

Kinvey Support

1 Comment

Answer

Khalid,


I have few questions for you:


  • Is there an active user when this code is executed?
  • What error do you see?
  • Currently how are you sending the SMS?


In case there is no active user, the updation of the new password could be done through a custom endpoint which would take the necessary parameters. If there is an active user, this code looks good to me.


Thanks,

Pranav

Kinvey Support


1 person likes this
Login or Signup to post a comment