小编Net*_*ian的帖子

刷新后,firebase Auth 当前用户返回null

这是我在个人资料页面上的代码,当我从 AuthService 的登录方法重定向时,这第一次工作正常

const user = firebase.auth().currentUser;
  if (user != null) {
    this.name = user.displayName;
    this.uid = user.uid;
  } else {
    this.name = "Unknown";
  }
Run Code Online (Sandbox Code Playgroud)

但是,如果我刷新页面或转到任何其他页面并返回此个人资料页面,则 currentUser 变为 null。

这是我的身份验证服务代码。

import * as firebase from "firebase/app";
import { auth } from "firebase/app";

      async googleSignin() {
    firebase
      .auth()
      .setPersistence(firebase.auth.Auth.Persistence.LOCAL)
      .then(async () => {
        const provider = new auth.GoogleAuthProvider();
        const credential = await this.afAuth.auth.signInWithPopup(provider);
        this.updateUserData(credential.user);
        this.router.navigate(["/profile"]);
        return;
      });
  }
Run Code Online (Sandbox Code Playgroud)

为什么我会丢失 currentUser?我什至还添加了 Persistence.LOCAL。

javascript firebase firebase-authentication angular

9
推荐指数
1
解决办法
4072
查看次数

MVC5 UseGoogleAuthentication 神秘方法

这可能是一个愚蠢的问题,但我在互联网上没有找到答案。我看到以下 MVC5 和 oAuth 代码

\n\n

app.UseFacebookAuthentication\napp.UseGoogleAuthentication();

\n\n

但是,我在调试器中的应用程序对象上没有看到任何名为 UseGoogleAuthentication 的方法。我确实在 Katana 代码中的 AppBuilder 上看到了 \xe2\x80\x9cUse\xe2\x80\x9d 方法。那么发生了什么?这个 \xe2\x80\x9capp.UseGoogleAuthentication();\xe2\x80\x9d 神秘方法是从哪里来的?我确信我错过了一些约定,但它是什么?

\n\n

提前致谢

\n

owin katana asp.net-mvc-5

3
推荐指数
1
解决办法
2803
查看次数