From 53b4b10947e69d658296e000818c8b716e8c3cd4 Mon Sep 17 00:00:00 2001 From: James Wang Date: Sat, 2 Jan 2016 14:49:48 -0500 Subject: [PATCH] Redirect user upon successful login/registration --- web/js/easyctf.js | 4 ++-- web/js/login.js | 6 ++++-- web/js/register.js | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/web/js/easyctf.js b/web/js/easyctf.js index b3788fa..6e4f22d 100644 --- a/web/js/easyctf.js +++ b/web/js/easyctf.js @@ -55,8 +55,8 @@ function display_message(containerId, alertType, message, callback) { $("#" + containerId).hide().slideDown("fast", "swing", function() { window.setTimeout(function () { $("#" + containerId).slideUp("fast", "swing", callback); - }); - }, 2000); + }, message.length * 75); + }); } function load_navbar() { diff --git a/web/js/login.js b/web/js/login.js index fc6e65e..28754fd 100644 --- a/web/js/login.js +++ b/web/js/login.js @@ -10,8 +10,10 @@ function login(email, password) { password: password }, function(data) { if (data.success == 1) { - display_message("status", "success", "Success!", function() {$("#login").removeAttr("disabled");}); - // wait then redirect or whatever + display_message("status", "success", "Success!", function() { + $("#login").removeAttr("disabled"); + window.location = "#/account"; + }); } else { display_message("status", "danger", data.message, function() {$("#login").removeAttr("disabled");}); } diff --git a/web/js/register.js b/web/js/register.js index bf1fcf4..e53fe6c 100644 --- a/web/js/register.js +++ b/web/js/register.js @@ -15,8 +15,10 @@ function register(name, username, password, password_confirm, email, captcha_res }, function(data) { $("#status").text(data.message); if (data.success == 1) { - display_message("status", "success", "Success!", function() {$("#register").removeAttr("disabled")}); - // wait then redirect or whatever + display_message("status", "success", "Success!", function() { + $("#register").removeAttr("disabled"); + window.location = "#/login"; + }); } else { display_message("status", "danger", data.message, function() {$("#register").removeAttr("disabled")}); grecaptcha.reset();