Fixes for fresh login check in API
- Fixes enter key causing two requests - Makes sure fresh login is handled for resources as well Fixes #1625
This commit is contained in:
parent
640012103c
commit
1655e79a74
1 changed files with 8 additions and 12 deletions
|
@ -6,9 +6,8 @@
|
||||||
angular.module('quay').factory('ApiService', ['Restangular', '$q', 'UtilService', function(Restangular, $q, UtilService) {
|
angular.module('quay').factory('ApiService', ['Restangular', '$q', 'UtilService', function(Restangular, $q, UtilService) {
|
||||||
var apiService = {};
|
var apiService = {};
|
||||||
|
|
||||||
var getResource = function(path, opt_background) {
|
var getResource = function(getMethod, operation, opt_parameters, opt_background) {
|
||||||
var resource = {};
|
var resource = {};
|
||||||
resource.url = path;
|
|
||||||
resource.withOptions = function(options) {
|
resource.withOptions = function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
return this;
|
return this;
|
||||||
|
@ -16,21 +15,13 @@ angular.module('quay').factory('ApiService', ['Restangular', '$q', 'UtilService'
|
||||||
|
|
||||||
resource.get = function(processor, opt_errorHandler) {
|
resource.get = function(processor, opt_errorHandler) {
|
||||||
var options = this.options;
|
var options = this.options;
|
||||||
var performer = Restangular.one(this.url);
|
|
||||||
|
|
||||||
var result = {
|
var result = {
|
||||||
'loading': true,
|
'loading': true,
|
||||||
'value': null,
|
'value': null,
|
||||||
'hasError': false
|
'hasError': false
|
||||||
};
|
};
|
||||||
|
|
||||||
if (opt_background) {
|
getMethod(opt_parameters, options, opt_background).then(function(resp) {
|
||||||
performer.withHttpConfig({
|
|
||||||
'ignoreLoadingBar': true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
performer.get(options).then(function(resp) {
|
|
||||||
result.value = processor(resp);
|
result.value = processor(resp);
|
||||||
result.loading = false;
|
result.loading = false;
|
||||||
}, function(resp) {
|
}, function(resp) {
|
||||||
|
@ -136,6 +127,10 @@ angular.module('quay').factory('ApiService', ['Restangular', '$q', 'UtilService'
|
||||||
};
|
};
|
||||||
|
|
||||||
var verifyNow = function() {
|
var verifyNow = function() {
|
||||||
|
if (!$('#freshPassword').val()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var info = {
|
var info = {
|
||||||
'password': $('#freshPassword').val()
|
'password': $('#freshPassword').val()
|
||||||
};
|
};
|
||||||
|
@ -234,7 +229,8 @@ angular.module('quay').factory('ApiService', ['Restangular', '$q', 'UtilService'
|
||||||
// If the method for the operation is a GET, add an operationAsResource method.
|
// If the method for the operation is a GET, add an operationAsResource method.
|
||||||
if (method == 'get') {
|
if (method == 'get') {
|
||||||
apiService[operationName + 'AsResource'] = function(opt_parameters, opt_background) {
|
apiService[operationName + 'AsResource'] = function(opt_parameters, opt_background) {
|
||||||
return getResource(buildUrl(urlPath, opt_parameters), opt_background);
|
var getMethod = apiService[operationName];
|
||||||
|
return getResource(getMethod, operation, opt_parameters, opt_background);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue