【问题标题】:How to save user information (userName) firebase new angular 2如何保存用户信息(用户名)firebase new angular 2
【发布时间】:2016-12-07 04:10:37
【问题描述】:

我需要保存我的 Firebase 用户名并在他登录时获取它,但我无法弄清楚。我应该在代码中添加什么?

  signUp(userEmail , userPassword){
    firebase.auth().createUserWithEmailAndPassword(userEmail, userPassword).catch(function(error) {
      // Handle Errors here.
      var errorCode = error.code;
      var errorMessage = error.message;
      // ...
    });

 signIn(userEmail , userPassword){
firebase.auth().signInWithEmailAndPassword(userEmail, userPassword).catch(function(error) {
  // Handle Errors here.
  var errorCode = error.code;
  var errorMessage = error.message;
  // ...
});

感谢您的回答。

【问题讨论】:

  • 那段代码不是已经创建用户了吗?是什么让您认为它不起作用?
  • 我想添加用户名,但我只能使用电子邮件和密码

标签: javascript typescript angular firebase angularfire


【解决方案1】:

我已经解决了这个问题。你只是链函数然后它看起来像

 firebase.auth().createUserWithEmailAndPassword(userEmail, userPassword).then(function (result) {

  firebase.database().ref('/users/' + result.uid).set({
    username: 'someOne',
    email:userEmail,
  });

  console.log(result);
}).catch(function (error) {
  // Handle Errors here.
  var errorCode = error.code;
  var errorMessage = error.message;
  // ...
});

【讨论】:

    猜你喜欢
    • 2019-04-29
    • 1970-01-01
    • 1970-01-01
    • 2017-04-21
    • 1970-01-01
    • 1970-01-01
    • 2019-03-08
    • 2019-07-21
    • 2020-08-10
    相关资源
    最近更新 更多