【问题标题】:firebase reset password controllerfirebase 重置密码控制器
【发布时间】:2018-05-31 19:48:01
【问题描述】:

昨天我的应用上线了,Ionic v1,有几个用户输入了错误的密码,无法登录应用。 该应用程序使用 Firebase 身份验证。我有一个指向数据库的 __refs 文件,并且尝试了很多方法来尝试使重置工作。 我试过引用 $firebaseAuth,当然我的 __refs,$firebase 然后使用 $firebase.auth()... 我没有编写这个应用程序的身份验证,所以我不确定它是如何工作的。我希望有人可以帮助我。

我的重置控制器

angular.module('formulaWizard').controller('ResetPasswordCtrl', 

function($scope, $ionicLoading, $firebaseAuth, __Refs) { $scope.user = { 电子邮件: '' }; $scope.errorMessage = null;

var fbAuth = $firebaseAuth(__Refs.rootRef);

$scope.resetPassword = function() {
  $scope.errorMessage = null;

  $ionicLoading.show({
    template: 'Please wait...'
  });

   fbAuth.sendPasswordResetEmail($scope.user.email)
      .then(showConfirmation)
      .catch(handleError);
};


function showConfirmation() {
  $scope.emailSent = true;
  $ionicLoading.hide();
}

function handleError(error) {
  switch (error.code) {
    case 'INVALID_EMAIL':
    case 'INVALID_USER':
      $scope.errorMessage = 'Invalid email';
      break;
    default:
      $scope.errorMessage = 'Error: [' + error.code + ']';
  }

  $ionicLoading.hide();
}
});

我的参考文件

angular.module('formulaWizard')
 .factory('__Refs', function ($firebaseArray, $firebaseObject) {
// Might use a resource here that returns a JSON arrayf
var ref = new Firebase('https://firebasedatabase.com/');
 return {
    rootRef: ref,
    customers: ref.child('customers'),

}
});

【问题讨论】:

    标签: firebase ionic-framework


    【解决方案1】:

    我不相信 Abimbola Idowu 在 HackHands 上提供的答案。
    自从我为答案付费后,我想我会与其他可能被此问题困扰的人分享。

    $scope.resetPassword = function() {
      $scope.errorMessage = null;
    
      $ionicLoading.show({
        template: 'Please wait...'
      });
    
       __Refs.rootRef.resetPassword({ email: $scope.user.email }, function(error) {
        if (error === null) {
          showConfirmation();
        } else {
          handleError()
        }
      });
    };
    

    这是 __refs 服务

    angular.module('formulaWizard')
    .factory('__Refs', function ($firebaseArray, $firebaseObject) {
    // Might use a resource here that returns a JSON arrayf
    var ref = new Firebase('https://firebasedatabase.com/');
      return {
        rootRef: ref,
    
      }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-13
      • 2013-01-14
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 2019-05-14
      • 2018-07-15
      相关资源
      最近更新 更多