弹出窗口出现然后立即关闭

L. *_*emi 8 firebase angularfire2

我正在尝试按照 github 上 angularfire2 文档中的指南进行操作,但是当我尝试打开用于 google 登录的弹出窗口时,它会立即关闭。

我试过不同的浏览器,但我不知道发生了什么。

这是我的表单组件的 HTML:

<div class="container " >
<h2 class="date">Wallet manager</h2>
<h1>SUBBO</h1>

<form>
  <div class="form-group">
    <label class="date" for="exampleInputEmail1">Email address</label>
    <input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
    <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
  </div>
  <div class="form-group">
    <label class="date" for="exampleInputPassword1">Password</label>
    <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
  </div>
  <button type="submit" (click)="login()" style="margin-top:20px" class="btn btn-outline-warning">Login</button>
  <button type="submit" (click)="logout()" style="margin-top:20px" class="btn btn-outline-warning">Logout</button>
</form>

</div>
Run Code Online (Sandbox Code Playgroud)

这是代码:

import { Component, OnInit } from '@angular/core';
import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';

@Component({
  selector: 'app-login-form',
  templateUrl: './login-form.component.html',
  styleUrls: ['./login-form.component.css']
})
export class LoginFormComponent implements OnInit {

  constructor(public afAuth: AngularFireAuth) {
  }
  login() {
    this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleProvider());
  }
  logout() {
    this.afAuth.auth.signOut();
  }

  ngOnInit() {
  }

}
Run Code Online (Sandbox Code Playgroud)

使用登录按钮,我调用 Login() 并且我希望窗口弹出并停留在那里,但它立即关闭。

我已经将项目上传到 Firebase,它给了我同样的问题:https : //subbo-wallet-manager.firebaseapp.com/

mac*_*ack 9

我在使用 Firebase 身份验证时遇到了同样的问题。我的解决方案是进入 Firebase 控制面板,选择我的项目,选择身份验证,然后在“登录方法”下,我必须将我的域添加到授权域列表中。一旦我这样做并重新加载页面,它就起作用了。