angularjssatellizer

Satellizer error


angular.module('starter')

   .controller('LoginCtrl', function($scope, $location, $stateParams, $ionicHistory, $http, $state, $auth, $rootScope) {

    $scope.loginForm = {}
    $scope.loginError = false;
    $scope.loginErrorText;

    $scope.login = function() {

        var credentials = {
            email: $scope.loginForm.email,
            password: $scope.loginForm.password
        }

        console.log(credentials);

        $auth.login(credentials).then(function() {
             console.log('im in login function' );
            // Return an $http request for the authenticated user
            $http.get('http://localhost:8000/api/v1/auth/user').success(function(response){
                // Stringify the retured data
                var user = JSON.stringify(response.user);

                // Set the stringified user data into local storage
                localStorage.setItem('user', user);

                // Getting current user data from local storage
                $rootScope.currentUser = response.user;
                // $rootScope.currentUser = localStorage.setItem('user');;

                $ionicHistory.nextViewOptions({
                  disableBack: true
                });

                $state.go('app.jokes');
            })
            .error(function(){
                $scope.loginError = true;
                $scope.loginErrorText = error.data.error;
                console.log($scope.loginErrorText);
            })
        });
    }
});

When i call the login function i get this error

POST http://localhost:8100/auth/login 404 (Not Found)

Is there problem with the satellizer?


Solution

  • I was also suffering from same issue. I just added

    $authProvider.loginUrl = myServer+ 'oauth/token';
    $authProvider.tokenName = 'access_token';
    $authProvider.tokenPrefix = 'myServerAuth';
    $authProvider.tokenHeader = 'Authorization';
    $authProvider.tokenType = 'Bearer';
    

    in my config and it worked fine.