mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-03-13 23:50:28 +01:00
31 lines
831 B
JavaScript
31 lines
831 B
JavaScript
'use strict';
|
|
|
|
// Config HTTP Error Handling
|
|
angular.module('users').config(['$httpProvider',
|
|
function ($httpProvider) {
|
|
// Set the httpProvider "not authorized" interceptor
|
|
$httpProvider.interceptors.push(['$q', '$location', 'Authentication',
|
|
function ($q, $location, Authentication) {
|
|
return {
|
|
responseError: function (rejection) {
|
|
switch (rejection.status) {
|
|
case 401:
|
|
// Deauthenticate the global user
|
|
Authentication.user = null;
|
|
|
|
// Redirect to signin page
|
|
$location.path('signin');
|
|
break;
|
|
case 403:
|
|
// Add unauthorized behaviour
|
|
break;
|
|
}
|
|
|
|
return $q.reject(rejection);
|
|
}
|
|
};
|
|
}
|
|
]);
|
|
}
|
|
]);
|