小编Eto*_*ity的帖子

Firebase身份验证不会持久存在

页面刷新后,身份验证似乎不会保留.即使使用后firebase.auth.Auth.Persistence.LOCAL.

每当我登录我的应用程序时,它都会成功将我重定向到仪表板.但是,当页面刷新时,无法访问仪表板.

这是我的代码.

文件名:login.component.ts

import { Router } from '@angular/router';
import { Component, OnInit } from '@angular/core';

import * as firebase from 'firebase/app';
import { Observable } from 'rxjs/Observable';
import { AngularFireAuth } from 'angularfire2/auth';
import { AngularFirestore } from 'angularfire2/firestore';

@Component({
    ...
})
export class LoginComponent implements OnInit {

    email: string = '';
    password: string = '';

    constructor(public afAuth: AngularFireAuth, private router: Router, private fb: FormBuilder) {}

    signIn(credentials) {
        this.email = credentials.email;
        this.password = credentials.password;

        this.afAuth.auth.setPersistence(firebase.auth.Auth.Persistence.LOCAL).then(() => …
Run Code Online (Sandbox Code Playgroud)

javascript firebase firebase-authentication angular-cli angular

5
推荐指数
1
解决办法
1947
查看次数