Firebase Facebook 登录检查用户是否存在 [英] Firebase Facebook login check if user exist

查看:25
本文介绍了Firebase Facebook 登录检查用户是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可与 firebase 配合使用的 facebook 登录系统,但我想检查我的 firebase 上是否存在用户(我不想添加它,只是想确定他是否存在,因为我想将用户重定向到另一个页面以完成其配置文件,完成后我想将其发送到 firebase).

I have an facebook login system which works with firebase but I want to check if user exist on my firebase (i don't want to add it, just want to make sure if he exist because I want to redirect user to another page to complete its profile, once its done I'll want to send it to firebase).

我只需要检查用户是否存在于我的数据库中.这是我尝试的代码,但它返回零错误并自动将用户添加到 firebase.

I just need to check if user exist on my db. Here is the code that I try but it returns nil error and it automatically add user to firebase.

let credential = FIRFacebookAuthProvider.credentialWithAccessToken(FBSDKAccessToken.currentAccessToken().tokenString)


FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in
        // ... 

}

推荐答案

您可以使用 reauthenticateWithCredential 方法来检查用户是否存在.

You can use reauthenticateWithCredential method to check user is exist or not.

检查本文档,部分 -> 重新验证用户

Check this Doc. , section -> Re-authenticate a user

let user = FIRAuth.auth()?.currentUser
var credential: FIRAuthCredential

// Prompt the user to re-provide their sign-in credentials

user?.reauthenticateWithCredential(credential) { error in
  if let error = error {
    // An error happened.
  } else {
    // User re-authenticated.
  }
}

如果用户重新认证成功,则表示用户存在...

If user re-authenticated successfully that means user is existed...

这篇关于Firebase Facebook 登录检查用户是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆