summaryrefslogtreecommitdiffstats
path: root/app/common/services/api-utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/common/services/api-utils.js')
-rw-r--r--app/common/services/api-utils.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index 73fe5a4..c8a7969 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -189,6 +189,31 @@ window.angular && (function (angular) {
console.log(error);
});
},
+ testPassword: function(username, password){
+ // 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({
+ method: 'POST',
+ url: DataService.getHost() + "/login",
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ 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 deferred.promise;
+ },
logout: function(callback){
$http({
method: 'POST',
OpenPOWER on IntegriCloud