module.exports = function($scope, $uibModalInstance, $http, $log) { var vm = this; vm.data = { email: null, password: null }; vm.ok = function() { var email = vm.data.email; var password = vm.data.password; // Encode authentication data. var authdata = base64.encode(email + ':' + password); return $http.post('/api/user/login', {}, { ignoreAuthModule: true, headers: { 'authorization': 'Basic ' + authdata } }).then(function(result) { $log.log(result); $uibModalInstance.close(result.data); }, function(response) { // FIXME Alexis Lahouze 2017-06-11 Handle error. $log.log("Error on login", response); }); }; vm.cancel = function() { $uibModalInstance.dismiss('cancel'); }; };