I did authorization with $cookies. Everything is work.

$http.post("/api/account/login", $scope.userData)
        .then(function onSuccess(response) {
            $cookies.put('token', response.data.access_token);
            $http.defaults.headers.common['Authorization'] = 'Bearer ' + 
response.data.access_token;

        }).catch(function onError(response) {
        console.log(response)
    });

I have return from backend and put all data to token and header. Its work and 
header too.

In my main module I want implement next attributes



$stateProvider


         .state('home', {
             url: '/',
             templateUrl: 'app/pages/home.html',
             controller: 'HomeController',
             authenticate: false,   //-this
         })

         .state('education', {
             url: '/education',
             templateUrl: 'app/pages/education.html',
             controller: 'EducationController',
             authenticate: false,   //-this


         })


I tried it to do by this example 
https://www.octobot.io/blog/2016-11-25-angularjs-ui-router-per-view-authorization/
 but no result. What must I do after "function onSuccess(response)" on login 
controller that my attributes "authenticate: false/true" will work? Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to