如何以与旧版 Firebase 类似的方式对用户进行身份验证? - 吴路由

How to Authenticate Users in a similar way from Legacy Firebase? - NgRoute

早些时候(来自遗留文档)我们可以使用这个结构并且它工​​作正常:

$routeProvider.when("/home", {
  // the rest is the same for ui-router and ngRoute...
  controller: "HomeCtrl",
  templateUrl: "views/home.html",
  resolve: {
    // controller will not be loaded until $waitForAuth resolves
    // Auth refers to our $firebaseAuth wrapper in the example above
    "currentAuth": ["Auth", function(Auth) {
      // $waitForAuth returns a promise so the resolve waits for it to complete
      return Auth.$waitForAuth();
    }]
  }
})
.when("/account", {
  // the rest is the same for ui-router and ngRoute...
  controller: "AccountCtrl",
  templateUrl: "views/account.html",
  resolve: {
    // controller will not be loaded until $requireAuth resolves
    // Auth refers to our $firebaseAuth wrapper in the example above
    "currentAuth": ["Auth", function(Auth) {
      // $requireAuth returns a promise so the resolve waits for it to complete
      // If the promise is rejected, it will throw a $stateChangeError (see above)
      return Auth.$requireAuth();
    }]
  }

但自从最近 Google IO(2016 年 5 月 18 日)以来,该文档现在 deprecated。我如何使用新规则验证我的用户?

我需要简单的决定,而不是$waitForAuth()$requireAuth()

您正在使用 AngularFire 1.x,它与 Firebase 2.x 一起使用。

新的 Firebase SDK 是 3.x,您需要使用 AngularFire 2.x。

AngularFire 网站上有一个很棒的 migration guide for AngularFire 1.x to 2.x

从该指南看来,您现在需要:

Old method         New method
$requireAuth() ->  $requireSignIn()   
$waitForAuth() ->  $waitForSignIn()