Ionic Auth Password Reset


#1

I’ve set up my app to use ionic auth for the sign up and login as per the tutorial and I’ve gotten the password reset function to work but I can’t figure out how to validate the email when requesting a reset or validate the code when confirming the reset. this allows anyone to access the app by simply putting any email in and then any code in.

request reset

$scope.userData = $ionicUser.details;
$scope.data = {
    email: 'test2@artisanideas.co.nz'
};

$scope.data = {
    email: ''
};
$scope.request = function() {
    console.log($scope.data.email);
    if($scope.data.email.length < 1) {
      $ionicPopup.alert({
       title: 'Error',
       template: 'Please input email address.'
      });
      return ;
    }
    
    $ionicAuth.requestPasswordReset($scope.data.email);
    var alertPopup = $ionicPopup.alert({
     title: 'Alert!',
     template: 'Email sent! Please check your email.'
    });

    alertPopup.then(function(res) {
     $state.go("confirmReset");
    });
};

}’

confirm reset
’$scope.data = {
code: ‘’,
newpassword: ‘’
};

$scope.error = '';

$scope.reset = function() {
  if($scope.data.code.length < 1 || $scope.data.newpassword.length < 1) {
     $ionicPopup.alert({
         title: 'Alert!',
         template: 'Please fill out information.'
     });
     return ;
  }
  $ionicAuth.confirmPasswordReset($scope.data.code, $scope.data.newpassword)
  
  var alertPopup = $ionicPopup.alert({
     title: 'Alert!',
     template: 'Password has been changed.'
 });'

#2

Hello,

You should display first an page that the user should put the email.
then when he will put the email redirect him to other page that it will ask for code and put the new password.


the first page the code is:

function ($scope, $stateParams, $ionicAuth,$state) {


 $scope.data = {
        'email': ''
    }

$scope.reset = function () {
    $ionicAuth.requestPasswordReset($scope.data.email);
    alert("emails has been send");
    $state.go('resetCode');
}

}

and for the second is:

function ($scope, $stateParams,$ionicAuth, $state, $ionicUser) {

 $scope.data = {
        'code': '',
        'newpassword':''
    }


$scope.reset = function () {
    $ionicAuth.confirmPasswordReset($scope.data.code, $scope.data.newpassword);
    alert("password changed");
    $state.go('login');
}


}

But for me i receive the code on the email but i have the problem with the reset function once i get 402 error