Return http promise on testPassword
Instead of creating a new promise with q.defer(), just return the
http promise. This is much simpler and the recommended solution.
Tested: Changed the password and verified the wrong old password
returned an error on a Witherspoon.
Change-Id: I1b412426da58ec3185f6d83bd53fdc984c7785e8
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index bc89eb1..980f1a2 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -193,8 +193,7 @@
// Calls /login without the current session to verify the given password is correct
// ignore the interceptor logout on a bad password
DataService.ignoreHttpError = true;
- var deferred = $q.defer();
- $http({
+ return $http({
method: 'POST',
url: DataService.getHost() + "/login",
headers: {
@@ -204,15 +203,8 @@
withCredentials: false,
data: JSON.stringify({"data": [username, password]})
}).then(function(response){
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- DataService.ignoreHttpError = false;
- deferred.resolve(content.data);
- }, function(error){
- DataService.ignoreHttpError = false;
- deferred.reject(error);
+ return response.data;
});
- return deferred.promise;
},
logout: function(callback){
$http({