0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Guard against multiple signup events

Fixes #1841
* Added initial flag "no" for submission into Signup View
* Flag set to "yes" if submit button clicked
* Error thrown if flag is "yes", thus no subsequent submission sent to API
* Flag set to "no" if ajax returns with error
This commit is contained in:
Gabor Javorszky 2014-01-26 22:38:50 +00:00
parent 6efc8ffed2
commit f3e67f9a76

View file

@ -64,6 +64,7 @@
Ghost.Views.Signup = Ghost.View.extend({
initialize: function () {
this.submitted = "no";
this.render();
},
@ -95,10 +96,12 @@
Ghost.Validate.check(name, "Please enter a name").len(1);
Ghost.Validate.check(email, "Please enter a correct email address").isEmail();
Ghost.Validate.check(password, "Your password is not long enough. It must be at least 8 characters long.").len(8);
Ghost.Validate.check(this.submitted, "Ghost is signing you up. Please wait...").equals("no");
if (Ghost.Validate._errors.length > 0) {
Ghost.Validate.handleErrors();
} else {
this.submitted = "yes";
$.ajax({
url: Ghost.paths.subdir + '/ghost/signup/',
type: 'POST',
@ -114,6 +117,7 @@
window.location.href = msg.redirect;
},
error: function (xhr) {
this.submitted = "no";
Ghost.notifications.clearEverything();
Ghost.notifications.addItem({
type: 'error',