From f6a068fdcef8b7650f010e4bb52f52a3b566e4bd Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Fri, 1 Apr 2016 20:08:00 -0400 Subject: add login test --- data/stuff/test/auth.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'data/stuff/test/auth.js') diff --git a/data/stuff/test/auth.js b/data/stuff/test/auth.js index 1bba095..408010b 100644 --- a/data/stuff/test/auth.js +++ b/data/stuff/test/auth.js @@ -91,6 +91,9 @@ jQuery(function($) { $('#create-user').click(function() { var me = $(this); + if (me.hasClass('disabled')) + return false; + // toggle loading me.toggleClass('disabled').find('.loading').toggleClass('hidden'); @@ -113,6 +116,43 @@ jQuery(function($) { return false; }); + $('#login').click(function() { + var me = $(this); + + if (me.hasClass('disabled')) + return false; + + // toggle loading + me.toggleClass('disabled').find('.loading').toggleClass('hidden'); + + send('test/login', { + email: $('#login-email').val(), + password: $('#login-password').val(), + }).always(function() { + // toggle loading + me.toggleClass('disabled').find('.loading').toggleClass('hidden'); + }).fail(function(r) { + alert('Error ' + r.responseText); + }).done(function(r) { + console.log(r); + }); + + // stop event + return false; + }); + + $('#login-user, #login-password').keydown(function(ev) { + if (ev.which == 13) { + setTimeout(function() { + // trigger login + $('#login').click(); + }, 10); + + // stop event + return false; + } + }); + $('#reload').click(reload); // load users -- cgit v1.2.3