i'm trying unlink email/password authentication user in swift on ios. i've read the documentation , managed link , unlink facebook authentication without problem. however, after linking email/password credentials successfully, providerdata
object nil. providerid
"firebase" when pass unlink code following error thrown:
error domain=firautherrordomain code=17016 "user not linked account given provider." userinfo={nslocalizeddescription=user not linked account given provider., error_name=error_no_such_provider}
the unlink code i'm using is:
let providerid = (firauth.auth()?.currentuser?.providerid)! print("trying unlink:",providerid) // providerid = "firebase" firauth.auth()?.currentuser?.unlinkfromprovider(providerid) { user, error in if let error = error { print("unlink error:", error) } else { // provider unlinked account print("unlinked...user.uid:", user!.uid, "anonymous?:", user!.anonymous) } }
reading docs , having got working facebook, expected providerdata array populated after email authentication. linking code wrong (it doesn't throw error , appears work fine)?
my linking code:
let credential = firemailpasswordauthprovider.credentialwithemail(email, password: password) firauth.auth()?.currentuser!.linkwithcredential(credential) { (user, error) in if user != nil && error == nil { // success self.success?(user: user!) dispatch_async(dispatch_get_main_queue(), { self.dismissviewcontrolleranimated(true, completion: nil) if type == "new" { print("new user logged in...") } if type == "existing" { print("existing user logged in...") } }) } else { print("login error:",error) self.showokalertwithtitle("login error", message: error!.localizeddescription) } }
any pointers of how can modify approach great.
to profile information retrieved sign-in providers linked user, use providerdata property.
if let user = firauth.auth()?.currentuser { profile in user.providerdata { // id of provider (ex: facebook.com) let providerid = profile.providerid } } else { // no user signed in. }
calling firauth.auth()?.currentuser?.providerid result "firebase".
Comments
Post a Comment