我在Firebase
应用中使用iOS
为用户提供服务器支持。
当有人想要更改其凭据(电子邮件/密码)或其显示名称时,我请求确认当前凭据。有没有办法(API)检查提供的凭据是否与当前登录的用户匹配,而不是执行注销并尝试再次登录,希望提供的凭据是正确的?
答案 0 :(得分:3)
使用以下方法使用firebase重新验证用户
let user = FIRAuth.auth()?.currentUser
var credential: FIRAuthCredential
// Prompt the user to re-provide their sign-in credentials
user?.reauthenticate(with: credential) { error in
if let error = error {
// An error happened.
} else {
// User re-authenticated.
}
}
电子邮件:
let credential = FIREmailPasswordAuthProvider.credentialWithEmail(email,` password: password)
Facebook:
let credential = FIRFacebookAuthProvider.credentialWithAccessToken(FBSDKAccessToken.currentAccessToken().tokenString)
Twitter的:
let credential = FIRTwitterAuthProvider.credentialWithToken(session.authToken, secret: session.authTokenSecret)
Google:
let authentication = user.authentication
let credential = FIRGoogleAuthProvider.credentialWithIDToken(authentication.idToken, accessToken: authentication.accessToken)
继承了描述ios中用户管理的firebase链接 ios user management in firebase