我正在学习Flutter,正在尝试使用StreamBuilder在用户注销时显示登录/注册页面,或者在用户登录时显示配置文件页面。我的代码如下:
身份验证服务:
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
class AuthUser {
AuthUser({@required this.uid, @required this.email});
final String uid;
final String ema
我使用的是firebase身份验证,我的导航栏取决于用户是否登录。当我加载网站时,如果用户之前没有注销,他应该仍然是登录的用户,Firebase onAuthStateChanged listener在100-300ms后返回user,所以我的导航栏无法确定用户是登录的还是not.So,导航栏显示登录和注册按钮300ms,然后firebase返回user,导航栏显示仪表板和注销按钮。 我使用的是vue,我尝试过在本地存储上保存UID和用户名,但我担心的是安全性。如果有人手动更改了本地存储数据怎么办?此外,用户可以注销,但在我的手动设置localStorage.setItem(' us
当我尝试执行我的flutter应用程序时,我得到了以下错误: ======== Exception caught by widgets library =======================================================
The following _CastError was thrown building VerifyEmail(dirty, dependencies: [_InheritedProviderScope<User?>], state: _VerifyEmailState#da862):
Null check opera
我目前正在做一个使用react,redux和firebase的next.js项目。当用户进入一个需要授权的页面时,如果他们没有通过身份验证,我会使用以下代码来重定向他们。 import React from 'react';
import Router from 'next/router';
import { firebase } from '../../firebase';
import * as routes from '../../constants/routes';
const withAuthorization =
在我的react应用程序中,我试图使用react-router-dom实现公共和私有路由。
我目前正在从firebase.auth().onAuthStateChanged()函数获得身份验证状态。
问题是,由于firebase.auth().onAuthStateChanged()函数是异步的,所以JSX块首先用authState of false呈现,然后firebase.auth().onAuthStateChanged()在返回JSX之后将authState设置为true。
因此,身份验证是正确的,但我的react应用程序停留在登录页面上。
PublicRoute.js
const P
我试图显示一个页面,只有当当前用户登录,否则要求他们登录。我正在使用firebase身份验证来实现这一点。
import Head from "next/head";
import { auth } from "../../components/firebase";
import { onAuthStateChanged } from "firebase/auth";
import Login from "../Login";
import AddProperty from "../../components/AddP
在使用firebase包时,从冷启动中识别用户身份验证的正确方法是使用函数,如下所示:
firebaseAuth.onAuthStateChanged(firebase.getAuth(), (user) => {
if (user) {
// User is signed in.
} else {
// No user is signed in.
}
});
firebase还提供了作为获取当前auth状态的一种方法。
getAuth似乎落后于onAuthStateChanged;getAuth().currentUser将在onAuthStateChang
我正在开发一个使用firebase的next.js应用程序。我需要使用firebase auth包来限制对页面的访问。with-firebase-authentication示例没有显示多个页面的身份验证。 import React from 'react';
import Router from 'next/router';
import { firebase } from '../../firebase';
import * as routes from '../../constants/routes';
const w
创建了一个新的类来管理一个地方的签入方法,一个没有颤振Widget的Dart类。
它给出了在跟随后有关防火墙初始化的错误。
Error:未创建Firebase应用程序'DEFAULT‘-调用Firebase.initializeApp()。没有它,_firebaseAuth是无用的。
这里的完整示例项目:
请帮帮忙,这太令人沮丧了。
StackTrace:
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
我正在看这段代码:
firebase.init({
onAuthStateChanged: function(data) { // optional but useful to immediately re-logon the user when he re-visits your app
console.log(data.loggedIn ? "Logged in to firebase" : "Logged out from firebase");
if (data.loggedIn) {
console.log("u
我的Firebase createUserWithEmailAndPassword函数没有注册用户。该应用程序有一个注册方法,但它不起作用,相反,它需要我手动注册一个用户在Firebase身份验证页面,然后它从那里登录。
尝试登录后,我收到以下错误消息
W/System (11597): Ignoring header X-Firebase-Locale because its value was null.
I/flutter (11597): [firebase_auth/user-not-found] There is no user record corresponding to
当用户加载不同的视图(替换显示Firebase信息的用户仪表板)时,一切都很好。
但是当用户返回到用户仪表板视图时,会抛出一个错误,页面上不会呈现任何内容。
误差warning.js?0f60:33 Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component. This is a no-op.
整个构成部分:
// register user comp