Firebase是否正在首次检查用户 [英] Is firebase checking for user first time

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

问题描述

在初始加载时,firebase会告诉我,是否通过触发事件来登录用户,例如:

On initial load, firebase tells me, if user is logged in by firing event like this:

firebase.auth().onAuthStateChanged(func...)

我想检查一下,firebase是否仍在检查它.就像在页面加载时显示微调框一样,等待firebase检查用户,然后根据是否找到用户来显示应用或登录/注册表单.

I want to check, if firebase is still checking it. Like show spinner when page loads, wait for firebase to check user and then show app or login/register form, considering user found or not.

现在我只需要显示页面,然后显示firebase,然后,如果firebase找到了用户,则重定向到应用.

Now I just have to show page, then init firebase, and later, if firebase founds user, redirect to app.

推荐答案

传递给onAuthStateChanged的侦听器将使用nullUser实例的参数进行调用.

The listener passed to onAuthStateChanged will be called with an argument that is either null or the User instance.

因此可以安全地假设Firebase正在检查您的initializeApp调用与被调用的onAuthStateChanged侦听器之间的身份验证状态.调用initializeApp时显示微调器,调用侦听器时将其隐藏.

So it's safe to assume that Firebase is checking the authentication status between your calling of initializeApp and the listener for onAuthStateChanged being called. Display the spinner when you call initializeApp and hide it when the listener is called.

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

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