ios - integrating security for user objects in swift -


i relatively new ios software development. trying add security user objects in parse app. have no idea on how add project.

should this?

func loginviewcontroller() {     pfuser.loginwithusernameinbackground("myname", password: "mypass") {         (user: pfuser?, error: nserror?) -> void in         if user != nil {             // stuff after successful login.              let user = pfuser.loginwithusername("my_username", password: "my_password")             user.username = "my_new_username" // attempt change username             user.save() // succeeds, since user authenticated on device.              // user non-authenticated method.             let query = pfuser.query()             let useragain = query!.getobjectwithid(user.objectid!) as! pfuser              useragain.username = "another_username"              // crash, sinse pfuser not authenticated             useragain.save()          } else {             // login failed. check error see why.          }         let currentuser = pfuser.currentuser()         if currentuser != nil {             // stuff user         } else {             // show signup or login screen.         }     } } 

or this?

func useronlynamechange() {     let user = pfuser.loginwithusername("my_username", password: "my_password")     user.username = "my_new_username" // attempt change username     user.save() // succeeds, since user authenticated on device.      // user non-authenticated method.     let query = pfuser.query()     let useragain = query!.getobjectwithid(user.objectid!) as! pfuser      useragain.username = "another_username"      // crash, sinse pfuser not authenticated     useragain.save() } 

or have done wrong?


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -