mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 15:09:32 -02:30
AC-325 We now check before each call to the API that the token is not empty. If empty, return false. The false will throw a javascript error to the console, but not noticeable, unless you're watching the console. Stops API login dialog box from appearing. User just sees login dialog with correct message.
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
}
|
||||
|
||||
body {
|
||||
//color: #171717;
|
||||
color: #171717;
|
||||
padding-top: 60px;
|
||||
}
|
||||
|
||||
@@ -11,13 +11,7 @@ angular.module('RestServices',['ngCookies','AuthService'])
|
||||
setUrl: function (url) {
|
||||
this.url = url;
|
||||
},
|
||||
|
||||
//auth: { 'Authorization': 'Token ' + Authorization.getToken() },
|
||||
auth: function() {
|
||||
var token = Authorization.getToken();
|
||||
return { 'Authorization': 'Token ' + token }
|
||||
},
|
||||
|
||||
|
||||
pReplace: function() {
|
||||
//in our url, replace :xx params with a value, assuming
|
||||
//we can find it in user supplied params.
|
||||
@@ -35,30 +29,53 @@ angular.module('RestServices',['ngCookies','AuthService'])
|
||||
args = (args) ? args : {};
|
||||
this.params = (args.params) ? args.params : null;
|
||||
this.pReplace();
|
||||
return $http({method: 'GET',
|
||||
url: this.url,
|
||||
headers: this.auth(),
|
||||
params: this.params
|
||||
});
|
||||
var token = Authorization.getToken();
|
||||
if (token) {
|
||||
return $http({method: 'GET',
|
||||
url: this.url,
|
||||
headers: { 'Authorization': 'Token ' + token },
|
||||
params: this.params
|
||||
});
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
post: function(data) {
|
||||
return $http({method: 'POST',
|
||||
url: this.url,
|
||||
headers: this.auth(),
|
||||
data: data });
|
||||
var token = Authorization.getToken();
|
||||
if (token) {
|
||||
return $http({method: 'POST',
|
||||
url: this.url,
|
||||
headers: { 'Authorization': 'Token ' + token },
|
||||
data: data });
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
put: function(data) {
|
||||
return $http({method: 'PUT',
|
||||
url: this.url,
|
||||
headers: this.auth(),
|
||||
data: data });
|
||||
|
||||
var token = Authorization.getToken();
|
||||
if (token) {
|
||||
return $http({method: 'PUT',
|
||||
url: this.url,
|
||||
headers: { 'Authorization': 'Token ' + token },
|
||||
data: data });
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
destroy: function(data) {
|
||||
return $http({method: 'DELETE',
|
||||
url: this.url,
|
||||
headers: this.auth(),
|
||||
data: data});
|
||||
var token = Authorization.getToken();
|
||||
if (token) {
|
||||
return $http({method: 'DELETE',
|
||||
url: this.url,
|
||||
headers: { 'Authorization': 'Token ' + token },
|
||||
data: data});
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
Reference in New Issue
Block a user