0

I am using $ionicAuth service that deals with registration and logging in/out. I followed this tutorial https://docs.ionic.io/services/auth/#emailpassword-authentication and https://docs.ionic.io/setup.html - for setting up ionic cloud and using the services. When I try to register, I get this error - $ionicAuth.signup is not a function.Please help me to fix this.

$scope.register = function(){

        $scope.error = '';
        $ionicAuth.signup($scope.registerData).then(function() {
            // `$ionicUser` is now registered
            $ionicAuth.login('basic', $scope.registerData).then(function(){
              $state.go('login');
            });
        }, function(err) {

            var error_lookup = {
                'required_email': 'Missing email field',
                'required_password': 'Missing password field',
                'conflict_email': 'A user has already signed up with that email',
                'conflict_username': 'A user has already signed up with that username',
                'invalid_email': 'The email did not pass validation'
            }

            $scope.error = error_lookup[err.details[0]];
        })
    }
user2301
  • 1,857
  • 6
  • 32
  • 63
  • Should it be Ionic.Auth.signup()? http://legacy.docs.ionic.io/docs/user-authentication – Mickers Mar 13 '17 at 14:24
  • @mickers - Yeah, I tried that also. It gives me this error -Ionic.Auth.signup is not a function – user2301 Mar 13 '17 at 14:50
  • My next suggestion is to see if $ionic or $ionicAuth in fact exist in that scope. Hover over that variable in the console to check. – Mickers Mar 13 '17 at 15:08
  • @Mickers I didnt get you. How can I check the variable exist in the scope? I know to inspect the elements... – user2301 Mar 13 '17 at 15:23
  • You can place a breakpoint in your code at line 3 in your script. Then once you've refreshed your page you can hover over the object to see if it's either undefined or a list of available properties/methods. – Mickers Mar 13 '17 at 15:31
  • @Mickers Under the Scope->Local -> It shows this: ChildScope :null – user2301 Mar 13 '17 at 16:10
  • @Mickers Thanks its working now. $ionicUser,$ionicAuth order in the controller function was misplaced. Thats why it was showing undefined. – user2301 Mar 13 '17 at 16:31
  • Awesome. An up-vote on any comment that helped you would be appreciated :) – Mickers Mar 13 '17 at 17:09

0 Answers0