javascript - Checking authentication in Laravel via Angular -


in angular app created service:

.factory('auth', function($http) {     return {         is_authenticated: function() {             return $http.get('/api/users/is_authenticated');         }     } }); 

my method in api backed laravel:

public function is_authenticated() {     if(auth::check())     {         return response::json(array('authenticated' => true));     }      return response::json(array('authenticated' => false)); } 

and in controller:

    auth.is_authenticated()         .success(function(data) {             $scope.is_authenticated = data.authenticated;             if(data.authenticated)                 console.log('yes');         }); 

when go /api/users/is_authenticated see nothing on page, however, when echo auth::check() there 1 on page.

in view have list ng-show="is_authenticated" it's not working.

what doing wrong here? i'm failing see problem. why 'yes' not being logged console?

and yes, have injected auth service controller.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -