Commit 3cca2209 authored by Evren Kutar's avatar Evren Kutar

Merge branch 'login_view'

parents 896f3a21 b15909cf
......@@ -101,7 +101,7 @@ app.config(['$routeProvider', function ($routeProvider) {
controller: 'StaffListCtrl',
resolve: {
loadMyCtrl: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load('components/student/student_controller.js');
return $ocLazyLoad.load('components/staff/staff_controller.js');
}],
loadMyService: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load('zetalib/forms/form_service.js');
......@@ -144,4 +144,27 @@ app.config(['$routeProvider', function ($routeProvider) {
}
}
});
});
\ No newline at end of file
}).config(['$httpProvider', function ($httpProvider) {
/**
* the interceptor for all requests to check response
* 4xx - 5xx errors will be handled here
*/
$httpProvider.interceptors.push(function ($q) {
return {
'response': function (response) {
//Will only be called for HTTP up to 300
return response;
},
'responseError': function (rejection) {
// if unauthorized then redirect to login page
if(rejection.status === 400) {
location.reload();
}
if(rejection.status === 401) {
location.path('#/login');
}
return $q.reject(rejection);
}
};
});
}]);
\ No newline at end of file
......@@ -85,5 +85,19 @@ describe('zaerp.auth module', function () {
})
);
// todo: test in case of 401 reload
//it('unauthorized 401 should redirect to login',
// inject(function ($httpBackend, $http, $location, $window) {
//
// $httpBackend.whenGET('http://127.0.0.1:8000/#/dashboard').respond(401, '');
//
// $http.get('http://127.0.0.1:8000/#/dashboard');
// expect($window.location == '/#/login');
//
// $httpBackend.flush();
// })
//);
});
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment