2015-12-24 04:03:55 +00:00
|
|
|
$("#registration-form").on("submit", function(e) {
|
|
|
|
e.preventDefault();
|
2015-12-24 04:31:50 +00:00
|
|
|
register($("#name").val(), $("#username").val(), $("#password").val(), $("#password_confirm").val(), $("#email").val(), $("#g-recaptcha-response").val());
|
2015-12-24 04:03:55 +00:00
|
|
|
});
|
|
|
|
|
2015-12-24 04:31:50 +00:00
|
|
|
function register(name, username, password, password_confirm, email, captcha_response) {
|
2016-01-02 18:20:12 +00:00
|
|
|
$("#register").attr("disabled", "disabled");
|
2015-12-24 04:03:55 +00:00
|
|
|
$.post("/api/user/register", {
|
|
|
|
name: name,
|
|
|
|
username: username,
|
|
|
|
password: password,
|
|
|
|
password_confirm: password_confirm,
|
2015-12-24 04:31:50 +00:00
|
|
|
email: email,
|
|
|
|
captcha_response: captcha_response
|
2015-12-24 04:03:55 +00:00
|
|
|
}, function(data) {
|
|
|
|
$("#status").text(data.message);
|
|
|
|
if (data.success == 1) {
|
2016-01-02 19:49:48 +00:00
|
|
|
display_message("status", "success", "Success!", function() {
|
|
|
|
$("#register").removeAttr("disabled");
|
|
|
|
window.location = "#/login";
|
|
|
|
});
|
2015-12-24 04:31:50 +00:00
|
|
|
} else {
|
2016-01-02 18:26:02 +00:00
|
|
|
display_message("status", "danger", data.message, function() {$("#register").removeAttr("disabled")});
|
2015-12-24 04:31:50 +00:00
|
|
|
grecaptcha.reset();
|
2015-12-24 04:03:55 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|