mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 18:21:12 +03:00
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:
parent
770d10ccc3
commit
30aa1d74d8
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
Loading…
Reference in New Issue
Block a user