Redirect user upon successful login/registration

This commit is contained in:
James Wang 2016-01-02 14:49:48 -05:00
parent f85b55e19b
commit 53b4b10947
3 changed files with 10 additions and 6 deletions

View file

@ -55,8 +55,8 @@ function display_message(containerId, alertType, message, callback) {
$("#" + containerId).hide().slideDown("fast", "swing", function() { $("#" + containerId).hide().slideDown("fast", "swing", function() {
window.setTimeout(function () { window.setTimeout(function () {
$("#" + containerId).slideUp("fast", "swing", callback); $("#" + containerId).slideUp("fast", "swing", callback);
}, message.length * 75);
}); });
}, 2000);
} }
function load_navbar() { function load_navbar() {

View file

@ -10,8 +10,10 @@ function login(email, password) {
password: password password: password
}, function(data) { }, function(data) {
if (data.success == 1) { if (data.success == 1) {
display_message("status", "success", "Success!", function() {$("#login").removeAttr("disabled");}); display_message("status", "success", "Success!", function() {
// wait then redirect or whatever $("#login").removeAttr("disabled");
window.location = "#/account";
});
} else { } else {
display_message("status", "danger", data.message, function() {$("#login").removeAttr("disabled");}); display_message("status", "danger", data.message, function() {$("#login").removeAttr("disabled");});
} }

View file

@ -15,8 +15,10 @@ function register(name, username, password, password_confirm, email, captcha_res
}, function(data) { }, function(data) {
$("#status").text(data.message); $("#status").text(data.message);
if (data.success == 1) { if (data.success == 1) {
display_message("status", "success", "Success!", function() {$("#register").removeAttr("disabled")}); display_message("status", "success", "Success!", function() {
// wait then redirect or whatever $("#register").removeAttr("disabled");
window.location = "#/login";
});
} else { } else {
display_message("status", "danger", data.message, function() {$("#register").removeAttr("disabled")}); display_message("status", "danger", data.message, function() {$("#register").removeAttr("disabled")});
grecaptcha.reset(); grecaptcha.reset();