disable registration while request in progress

This commit is contained in:
Matteo Pagliazzi
2015-05-06 15:43:30 +02:00
parent 84a4c36c7e
commit 8066589268
2 changed files with 7 additions and 1 deletions

View File

@@ -15,11 +15,13 @@ angular.module('habitrpg')
var runAuth = function(id, token) {
User.authenticate(id, token, function(err) {
$scope.registrationInProgress = false;
$window.location.href = ('/' + window.location.hash);
});
};
function errorAlert(data, status, headers, config) {
$scope.registrationInProgress = false;
if (status === 0) {
$window.alert(window.env.t('noReachServer'));
} else if (!!data && !!data.err) {
@@ -29,6 +31,8 @@ angular.module('habitrpg')
}
};
$scope.registrationInProgress = false;
$scope.register = function() {
/*TODO highlight invalid inputs
we have this as a workaround for https://github.com/HabitRPG/habitrpg-mobile/issues/64
@@ -36,6 +40,8 @@ angular.module('habitrpg')
var scope = angular.element(document.getElementById('registrationForm')).scope();
if (scope.registrationForm.$invalid) return;
$scope.registrationInProgress = true;
var url = ApiUrl.get() + "/api/v2/register";
if($rootScope.selectedLanguage) url = url + '?lang=' + $rootScope.selectedLanguage.code;
$http.post(url, scope.registerVals).success(function(data, status, headers, config) {