【问题标题】:Real-Time Slack clone with AngularFire使用 AngularFire 进行实时 Slack 克隆
【发布时间】:2016-10-29 10:23:20
【问题描述】:

我尝试完成本教程 https://thinkster.io/angularfire-slack-tutorial#authenticating-users-using-angularfire

我遇到的问题是 Firebase 身份验证。在代码中没有错误,但它不想与 base 连接,错误是:

Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/

我不知道该怎么办,如果有人在玩这个并且知道答案,请告诉我,它在过去 3 天困扰着我。

【问题讨论】:

  • 消息看起来很简单,谷歌希望你更新firebase的身份验证组件。
  • 好吧,我知道,但是怎么做。文档在 firebase 站点上很混乱。我只需要在本教程中这样做。

标签: angularjs authentication firebase firebase-realtime-database slack


【解决方案1】:

您学习的教程是为 Firebase 2.x 编写的。在 firebase.google.com 上创建的项目只能使用 Firebase 3.x 的身份验证。

您要么必须找到更新的教程(例如this Firebase codelab),要么在Firebase legacy console 上创建一个项目。仅当您也在该旧版控制台上创建帐户时,最后一个选项才可用。

【讨论】:

    【解决方案2】:

    这个问题你解决了吗?

    这不是太复杂,我现在用 Firebase 3.x 运行 thinkster 示例。

    从代码中某处的 firebase 控制台复制 Web 应用配置代码(我把它放在 app.js 的开头):

    var config = {
      apiKey: "xxxxxx",
      authDomain: "projectid.firebaseapp.com",
      databaseURL: "https://projectid.firebaseio.com",
      storageBucket: "projectid.appspot.com",
    };
    firebase.initializeApp(config);
    var FirebaseUrl = firebase.database().ref();
    

    将所有 ref 变量更改为这种格式:

    var channelMessagesRef = FirebaseUrl.child('channelMessages');
    

    根据以下内容替换 auth 函数:

    https://github.com/firebase/angularfire/blob/master/docs/migration/1XX-to-2XX.md

    (还有一些“key()”必须替换为“key”)

    我想就是这样。如果您遇到问题,请告诉我。

    还有一个注意事项:

    规则文件有误,它向所有人提供了对私人消息的读取权限。我把它改成了这个:

    "userMessages":{
      "$uid1":{
        ".read": "$uid1 === auth.uid",
        "$uid2":{
            ".read": "$uid2 === auth.uid",
          "$messageId":{
            ".read": "auth !== null && ($uid1 === auth.uid || $uid2 === auth.uid)",
            ".write": "auth !== null && newData.child('uid').val() === auth.uid",
            ".validate": "$uid1 < $uid2 && newData.child('timestamp').exists()",
            "body":{
              ".validate": "newData.exists() && newData.val().length > 0"
            }
          }
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-12
      • 2012-07-13
      • 1970-01-01
      • 2017-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多