2016-04-30 132 views
1

火力地堡提供了一些簡單的方法來create users火力地堡,餘燼和餘燼創建用戶

我目前使用的餘燼(附加)與火力地堡,我想知道如何將其轉化灰燼中使用:

var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com"); 
ref.createUser({ 
    email: "[email protected]", 
    password: "correcthorsebatterystaple" 
}, function(error, userData) { 
    if (error) { 
    switch (error.code) { 
     case "EMAIL_TAKEN": 
     console.log("The new user account cannot be created because the email is already in use."); 
     break; 
     case "INVALID_EMAIL": 
     console.log("The specified email is not a valid email."); 
     break; 
     default: 
     console.log("Error creating user:", error); 
    } 
    } else { 
    console.log("Successfully created user account with uid:", userData.uid); 
    } 
}); 

因此,您可以創建一個用戶,將其保存到Ember Data並將其保存在Firebase中?還有其他方法changeEmail(),changePassword()等...所以我只是尋找一個例子來應用這個Emberfire?

回答

0

隨着火力地堡隊的幫助下,這裏是解決方案:

在控制器/混入/組件,你會定義你的火力點連接,然後在你的行動,你可以使用火力的代碼,如圖他們的文檔進行了一些小修改:

{ 
    firebase: Ember.inject.service(), 
    actions: { 
     submission: function(){ 
      const ref = this.get('firebase'); 
      ref.createUser({ 
       email: this.get('email'), 
       password: this.get('password') 
      }, function(error, userData) { 

      if (error) { 

       switch (error.code) { 

        case "EMAIL_TAKEN": 
         console.log('user already exists'); 
        break; 
        case "INVALID_EMAIL": 
         console.log('your email looks wrong'); 
        break; 
        case "INVALID_PASSWORD": 
         console.log('your password looks incorrect'); 
        break; 
        default: 
         console.log(error.message); 

       } 

      } else { 

       console.log('record added!'); 
       console.log(userData); 

      } 


      }); 

     } 
    } 

} 
+0

這仍然有效嗎? – SuperUberDuper

+0

nope,ref.createUser對我來說是undef – SuperUberDuper

+0

@SuperUberDuper您使用的是哪個版本的ember和firebase? – Matt