问题描述
因此,我的应用可以选择使用Google登录。单击Google提供的按钮后,将打开Web视图并让用户输入其凭据。在允许应用访问他们的信息后,应用程序然后签署用户并将SignInViewController更改为TabBarController(他们现在可以相应地进行交互)。
So my app has the option to sign in with Google. Upon clicking the button that Google provides, a web view opens and has the user input their credentials. After allowing the app to access their information the app then signs the user in and changes the SignInViewController to the TabBarController (where they can now interact accordingly).
当用户按下时一个Signout按钮,他们会按照人们的预期定向到登录屏幕。但奇怪的是,如果用户再次按下谷歌按钮,他们会自动登录,根本不需要进一步的身份验证,也无法删除他们的帐户。他们是否可以清除谷歌帐户凭据,以保护用户免遭意外盗窃?
When the user presses a Signout button they are directed to the login screen as one would expect. But the odd thing is, if the user presses the google button again they are automatically signed in with no further authentication at all and no option to remove their account. Is their a way to clear the google account credentials as to protect the users from accidental theft?
登录功能:
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) {
if let error = error {
print(error.localizedDescription)
return
}
let authentication = user.authentication
let credential = FIRGoogleAuthProvider.credentialWithIDToken(authentication.idToken, accessToken: authentication.accessToken)
FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in
// ...
SignInViewController().signedIn(user)
}
// ...
}
退出功能:
func signOutOverride() {
do {
try! FIRAuth.auth()!.signOut()
CredentialState.sharedInstance.signedIn = false
// Set the view to the login screen after signing out
let storyboard = UIStoryboard(name: "SignIn", bundle: nil)
let loginVC = storyboard.instantiateViewControllerWithIdentifier("SignInVC") as! SignInViewController
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.window?.rootViewController = loginVC
} catch let signOutError as NSError {
print ("Error signing out: \(signOutError)")
}
}
推荐答案
Swift
尝试 GIDSignIn.sharedInstance()。signOut()
目标 - c
[[GIDSignIn sharedInstance] signOut];
这篇关于如何在经过身份验证后退出Google的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!