aboutsummaryrefslogtreecommitdiff
path: root/www/authenticate.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/authenticate.js')
-rw-r--r--www/authenticate.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/www/authenticate.js b/www/authenticate.js
new file mode 100644
index 0000000..2d72480
--- /dev/null
+++ b/www/authenticate.js
@@ -0,0 +1,33 @@
+jQuery(function($) {
+ var email;
+
+ navigator.id.beginAuthentication(function(email_) {
+ email = email_;
+ $('#email').val(email);
+ });
+
+ var onAuthentication = function() {
+ var password = $('#password').val();
+ $.ajax({
+ type: 'POST',
+ url: '/browserid/login.pl',
+ dataType: 'json',
+ data: { email: email, password: password },
+ success: function(sig, status, xhr) {
+ console.log("Login successful!");
+ navigator.id.completeAuthentication();
+ },
+ error: function(reason, status, xhr) {
+ navigator.id.raiseAuthenticationFailure(reason.responseText);
+ }
+ });
+ return false;
+ };
+
+ var onCancel = function() {
+ navigator.id.cancelAuthentication();
+ };
+
+ $('#auth-form').submit(onAuthentication);
+ $('.cancel').click(onCancel);
+});