小编Ron*_*ton的帖子

Firebase v3 createUserWithEmailAndPassword.然后是Promise

Firebase v3参考指南表明createUserWithEmailAndPassword(email, password)返回firebase.Promise包含非null firebase.User.

使用基于密码的帐户指南的Firebase v3 使用Firebase进行身份验证显示以下示例

firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
  // Handle Errors here.
  var errorCode = error.code;
  var errorMessage = error.message;
  // ...
});
Run Code Online (Sandbox Code Playgroud)

我的问题是,我想启动一个函数,将用户添加到users我的实时数据库中的节点.我想要包括我从网站注册表单中收集的用户显示名称.所以,似乎我想要做一个.then,如果createUserWithEmailAndPassword方法成功,我想触发一个将新用户(带有显示名称)写入我的Realtime Database users节点的函数.

如何将示例脚本修改为.then样式?

firebase firebase-authentication firebase-realtime-database

18
推荐指数
1
解决办法
2万
查看次数

使用Firebase DataSnapshot.forEach进行Promise.all

我有一些HTML选择(下拉列表),这些选项是从名为"状态"的Firebase节点填充的(参见下图).在选择城市时,以下功能会触发,并应检索该城市中发生的所有会议.有一个单独的"会议"节点,每个会议都有各种键/值对,如街道,时间等.

我(我认为我)想要使用Promise.all,因为我想在DataSnapshot.forEach中进行Firebase读取(每个meetingID上的.once).以下不起作用.

function loadMeetings(city,state){
    //$('#meetingsTable').empty();
    var reads = [];
    ref.child('states').child(state).child(city).once('value').then(function(snapshot) {
        snapshot.forEach(function(childSnapshot) {
            var id = childSnapshot.key();
            var dfd = ref.child('meetings').child(id).once('value').then(function(snap) {
                // The Promise was fulfilled.
            }, function(error) {
                // The Promise was rejected.
                console.error(error);
            });
            reads.push( dfd );
        });       
    }, function(error) {
        // The Promise was rejected.
        console.error(error);
    });

    Promise.all(reads).then(function(values) { 
      console.log(values); // [snap, snap, snap] 
    });
}
Run Code Online (Sandbox Code Playgroud)

{
  "geofire" : {
    "25dbab9c-8e4e-45ce-a69b-8641b6579560" : {
      ".priority" : "9q5cc9ye4w",
      "g" : "9q5cc9ye4w",
      "l" : [ 34.0677809, -118.4016105 ]
    }, …
Run Code Online (Sandbox Code Playgroud)

javascript firebase es6-promise

11
推荐指数
1
解决办法
9172
查看次数

Firebase v3 updateProfile方法

火力地堡V3验证提供的updateProfile是通过方法displayNamephotoURL对火力地堡.

我的理解是,这些属性是在用户登录时从第三方oAuth提供商Google,Facebook,Twitter或GitHub中检索到的.如果是基于密码的身份验证,则无法从管理控制台访问或查看这些身份验证.

我可以存储密码验证帐户的此信息吗?如果可以,我可以通过管理控制台查看/管理此信息吗?

顺便说一句:我知道这可以存储在users节点/分支下的实时数据库中,但我要求将这些信息存储在Firebase Auth系统中.

在此输入图像描述

// Updates the user attributes:
user.updateProfile({
  displayName: "Jane Q. User",
  photoURL: "https://example.com/jane-q-user/profile.jpg"
}).then(function() {
  // Profile updated successfully!
  // "Jane Q. User"
  var displayName = user.displayName;
  // "https://example.com/jane-q-user/profile.jpg"
  var photoURL = user.photoURL;
}, function(error) {
  // An error happened.
});

// Passing a null value will delete the current attribute's value, but not
// passing a property won't change the current attribute's value:
// Let's say we're …
Run Code Online (Sandbox Code Playgroud)

firebase firebase-authentication

6
推荐指数
1
解决办法
7034
查看次数

Firebase Auth:链接匿名帐户

文档将匿名帐户转换为永久帐户指出了该过程的 3 个步骤,但步骤 2 似乎违反了步骤 1。

  1. 当用户注册时,完成用户身份验证提供程序的登录流程,直到(但不包括)调用 Auth.signInWith 方法之一。例如,获取用户的 Google ID 令牌、Facebook 访问令牌或电子邮件地址和密码。
  2. 获取新身份验证提供程序的 AuthCredential:var credential = firebase.auth.FacebookAuthProvider.credential( response.authResponse.accessToken);
  3. 将 AuthCredential 对象传递给登录用户的链接方法...

我的问题是:步骤 2.仅在调用步骤 1执行的方法之一后才response存在。如何将匿名帐户与 oAuth 帐户关联?Auth.signInWith

firebase firebase-authentication

6
推荐指数
1
解决办法
2458
查看次数

.remove()方法的Firebase安全规则

我想在我的数据上限制.remove()方法 - 只允许作者/创建者删除节点.这可能吗?

我有标准的用户树和一对数据树geoFire和一个命名的细节."详细信息"包含的节点包含时间戳和用户(与auth.uid匹配)等条目.

firebase

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

MDC-Web 排版:字体自定义

MDC排版特有的Roboto字体,或者我们可以与其他谷歌的字体,如果这样实施,简直到应用建议的方式font-familyCSS来body

最后,似乎所有头元素联系在一起的<h1>元素,这似乎打破HTML5的语义性质,即h1通常具有高于意义h5

material-components material-components-web

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

将 HTML 转换为 JavaScript 的工具 (.createElement)?

我有 HTML,但我想以编程方式创建它。我知道如何使用 JavaScript 的.createElement .appendChild方法来做到这一点,但它很耗时。我在网上找不到这样的转换工具。

有谁知道是否有一个工具(在线工具)可以获取我的 HTML 片段并生成将其添加到我的文档所需的 JavaScript?

javascript

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

Firestore - 清理文本区域输入?

我在Cloud Firestore 安全规则文档的编写条件中看到,可以针对新写入运行(服务器端)自定义函数。我的问题是:textarea在将用户输入写入/保存到 FireStore 之前,我什至需要担心对其进行消毒,还是 Firestore 会自动执行此操作?

如果我需要清理用户输入,那么 javascript 函数会是什么样子来做到这一点?我应该禁止或从字符串中删除哪些字符?提前致谢。

javascript firebase-security google-cloud-firestore

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

Firebase:调试权限不足

Uncaught (in promise) Error: Missing or insufficient permissions.

我有一个大型应用程序,扩展错误对象根本没有帮助我。有没有办法读取 Firestore 中的权限错误日志,以便我可以看到什么document或被collection禁止?

firebase google-cloud-firestore

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

Firebase - auth.uid是共享密钥吗?

看来,当有人通过oAuth进行身份验证时,Firebase会创建一个类似于某个内容的uid google:111413554342829501512.

在Firebase规则中,您可以执行(读取和/或写入):

".read": "root.child('users').child(auth.uid).child('isAdmin').val() == true"
Run Code Online (Sandbox Code Playgroud)

是否因为使用HTTPS而无法通过嗅探网络来阅读消息?这是它的工作原理 - UID是Firebase规则使用的共享密钥吗?

经过firebase:session::ack身份验证后,我在浏览器中看到UID在本地存储中.

firebase firebase-authentication

4
推荐指数
1
解决办法
1509
查看次数