AngularFire将简单登录电子邮件同步到个人资料 - 电子邮件

时间:2014-04-01 18:30:40

标签: angularjs firebase angularfire

*我正在处理angularfire-seed内的示例代码。

经过身份验证的用户在帐户页面上更新其个人资料电子邮件时,如何更新Firebase简易登录电子邮件值?

1 个答案:

答案 0 :(得分:0)

account.html页面调用updateEmail

<button ng-click="updateEmail()">update email</button>

直到AccountCtrl controller的角钩:

$scope.updateEmail = function() {
    $scope.reset();
    // disable bind to prevent junk data being left in firebase
    $scope.unBindAccount();
    changeEmailService(buildEmailParms());
  };

调用changeEmailService

基本上,changeEmailService会创建一个新帐户,对其进行验证,然后删除旧帐户。然后它将数据更新为/ user路径。它使用链式承诺回调的这种算法:

        // execute activities in order; first we authenticate the user
        authenticate()
           // then we fetch old account details
           .then( loadOldProfile )
           // then we create a new account
           .then( createNewAccount )
           // then we copy old account info
           .then( copyProfile )
           // and once they safely exist, then we can delete the old ones
           .then( removeOldProfile )
           .then( removeOldLogin )
           // success
           .then( function() { cb && cb(null) }, cb )
           .catch( errorFn );
相关问题