Firebase - 删除并重新安装应用程序不会取消对用户的身份验证 [英] Firebase - Deleting and reinstalling app does not un-authenticate a user

查看:24
本文介绍了Firebase - 删除并重新安装应用程序不会取消对用户的身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下代码对用户进行身份验证后(以下是我的代码的修剪版本,因此仅显示成功登录逻辑)...

After authenticating a user with the following code (below is a trimmed version of my code, so only the successful login logic is shown)...

let firebaseReference = Firebase(url: "https://MY-FIREBASE.firebaseio.com")

 

FBSession.openActiveSessionWithReadPermissions(["public_profile", "user_friends"], allowLoginUI: true,
    completionHandler: { session, state, error in

        if state == FBSessionState.Open {
            let accessToken = session.accessTokenData.accessToken
            firebaseReference.authWithOAuthProvider("facebook", token: accessToken,
                withCompletionBlock: { error, authData in

                    if error != nil {
                        // Login failed.
                    } else {
                        // Logged in!
                        println("Logged in! (authData)")
                    }
            })
        }
    })
}

(即启动并运行应用程序,登录成功).

(I.e. Launching and running the app, logging in successfully).

如果您随后删除该应用程序并在同一设备上重新安装它,则此调用(我在应用程序委托中使用它来确定用户是否已登录)将始终返回他们已登录.

If you then delete the app and reinstall it on the same device, this call - which I am using in the app delegate to determine if a user is logged in - will always return that they are logged in.

if firebaseReference.authData == nil {
    // Not logged in
} else {
    // Logged in
}

这是为什么?我原以为删除应用程序并重新安装它应该会擦除所有数据.

Why is that? I would have thought deleting the app and reinstalling it should wipe all data.

如果您在 iOS 模拟器中重置内容和设置,并安装应用程序,firebaseReference.authData 属性将再次nil.

If you reset the Content and Settings in the iOS simulator, and the install the app, the firebaseReference.authData property will once again be nil.

推荐答案

Firebase 身份验证会话保留在用户设备上的 iOS 钥匙串中.卸载应用程序时不会删除应用程序的钥匙串数据.

The Firebase authentication session is persisted on the user's device in the iOS keychain. The keychain data for the application is not removed when the application is uninstalled.

如果您想手动清除数据,您可以将一些额外的元数据与您的应用程序一起存储,并手动调用 FirebaseRef.unauth() 来清除持久的会话.请参阅#4747404:卸载应用程序时删除钥匙串项目供额外参考.

If you're looking to manually clear the data, you can store some additional metadata along with your application and manually call FirebaseRef.unauth() to clear the persisted session. See #4747404: Delete keychain items when an app is uninstalled for an additional reference.

这篇关于Firebase - 删除并重新安装应用程序不会取消对用户的身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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