【发布时间】: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'),
}
});
【问题讨论】: