简体   繁体   English

Firebase Authentication ( Email & Password ) 如何查看现有用户

[英]Firebase Authentication ( Email & Password ) how to check existing user

I'm using Firebase Auth in my app.我在我的应用程序中使用 Firebase Auth。 I wrote code in onStart() .我在onStart()中编写了代码。

private fun checkLogged() {
    if (Firebase.auth.currentUser != null) {
        startActivity(Intent(this@LoginActivity, MainActivity::class.java))
        finish()
    } else {
        auth.signOut()
    }
}

But when I disable or delete this user in the console, It's still logged in. How can I edit code correctly?但是当我在控制台中禁用或删除该用户时,它仍然处于登录状态。如何正确编辑代码?

When a user is successfully signed in with Firebase, then it receives a token that is valid for about an hour.当用户使用 Firebase 成功登录后,它会收到一个有效期约为一个小时的令牌。 If you disable a user in the Firebase console, it doesn't mean that the access is restricted too.如果您在 Firebase 控制台禁用用户,并不意味着访问也受到限制。 No, the user can still have access for about an hour.不,用户仍然可以访问大约一个小时。 After that period of time, the token that was previously generated needs to be refreshed, but the operation will fail since the user account is disabled.这段时间过后,需要刷新之前生成的令牌,但由于用户帐户被禁用,操作将失败。 A disabled account cannot get a new token.禁用的帐户无法获得新令牌。 So the user can still have access until the access will be automatically revoked.因此,在访问权限被自动撤销之前,用户仍然可以访问。

If you want to remove that access before the token expires, then you should consider keeping an additional list of "banned" UIDs and maintaining it over time.如果你想在令牌过期之前删除该访问权限,那么你应该考虑保留一个额外的“禁止”UID 列表并随着时间的推移维护它。 For example, you can keep a global array of bannedUIDs in a Firestore document, and add the UID to that array.例如,您可以在Firestore文档中保留一个全局的 bannedUID 数组,并将 UID 添加到该数组中。 Then, in your security rules, you can check if that particular UID is banned or not.然后,在您的安全规则中,您可以检查该特定 UID 是否被禁止。 If that UID exists inside that array, then Firebase servers will reject the operation, otherwise, it can continue to use your app.如果该 UID 存在于该数组中,则 Firebase 服务器将拒绝该操作,否则,它可以继续使用您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase 邮箱/密码验证 - 如何要求 email 验证? - Firebase email/password authentication - how to require email verification? Firebase 身份验证:通过 Email 查找用户 - Firebase Authentication : Lookup a user by Email 忘记 Firebase 的密码 email 地址无效的身份验证 - Forget password for Firebase Authentication with invalid email address 我如何检查 email 是否已存在于身份验证 firebase 中 - how I can check if the email is already exist in authentication firebase Firebase,通过具有唯一密码要求的 Email 更改用户密码 - Firebase, Changing User password via Email with unique password requirements 如何将重置密码 email 发送给在 React Native firebase 中注册的用户 email? - How to send a reset password email to user registered email in react native firebase? 如何在 Firebase 身份验证上区分电子邮件验证用户和非验证用户? - How to distinguish email-verified user from non-verified user on Firebase Authentication? 如何在 Firebase 身份验证中限制 email 域 - How to restrict email domains in Firebase Authentication 如何在 Firebase 中使用电子邮件和电话进行身份验证? - How to use email and phone to authentication in Firebase? Flutter:检查OTP认证后是现有用户还是新用户 - Flutter: Check if existing user or new user after OTP Authentication
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM