From e6363857d04b5ae4594d5e3358763a6f3706cfc1 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 23 Feb 2015 16:08:43 +0000 Subject: Add core registration html/js --- static/client/register/index.html | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 static/client/register/index.html (limited to 'static/client/register/index.html') diff --git a/static/client/register/index.html b/static/client/register/index.html new file mode 100644 index 0000000000..2248d6e5a8 --- /dev/null +++ b/static/client/register/index.html @@ -0,0 +1,35 @@ + + + Registration + + + + + + +
+
+ Create account:
+ +
+ +
+ +
+ +
+ +
+ + +
+ +
+ + +
Your home server stores all your conversation and account data.
+
+
+ + + -- cgit 1.4.1 From e36b18ad5b271ebba7620dff74647fec8ff55fbf Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 23 Feb 2015 17:09:11 +0000 Subject: Get everything working --- static/client/register/index.html | 14 ++-- static/client/register/js/register.js | 123 +++++++++++++++++++++++++++++----- 2 files changed, 113 insertions(+), 24 deletions(-) (limited to 'static/client/register/index.html') diff --git a/static/client/register/index.html b/static/client/register/index.html index 2248d6e5a8..d7ed8a1fe7 100644 --- a/static/client/register/index.html +++ b/static/client/register/index.html @@ -2,6 +2,7 @@ Registration + @@ -18,16 +19,11 @@

+ +
+
-
- - -
- -
- - -
Your home server stores all your conversation and account data.
+
diff --git a/static/client/register/js/register.js b/static/client/register/js/register.js index b8a9247e6d..38408f731f 100644 --- a/static/client/register/js/register.js +++ b/static/client/register/js/register.js @@ -1,23 +1,116 @@ -window.matrixRegistration = {}; +window.matrixRegistration = { + endpoint: location.origin + "/_matrix/client/api/v1/register" +}; var setupCaptcha = function() { - if (!window.matrixRegistrationConfig) { - return; - } - console.log("Setting up ReCaptcha"); - var public_key = window.matrixRegistrationConfig.recaptcha_public_key; - if (public_key === undefined) { - console.error("No public key defined for captcha!"); + if (!window.matrixRegistrationConfig) { return; } - Recaptcha.create(public_key, - "regcaptcha", - { - theme: "red", - callback: Recaptcha.focus_response_field + $.get(matrixRegistration.endpoint, function(response) { + var serverExpectsCaptcha = false; + for (var i=0; i "+JSON.stringify(response)); + submitPassword(user, pwd, response.session); + }).error(function(err) { + Recaptcha.reload(); + errorFunc(err); }); }; +var submitPassword = function(user, pwd, session) { + console.log("Registering..."); + var data = { + type: "m.login.password", + user: user, + password: pwd, + session: session + }; + $.post(matrixRegistration.endpoint, JSON.stringify(data), function(response) { + matrixRegistration.onRegistered( + response.home_server, response.user_id, response.access_token + ); + }).error(errorFunc); +}; + +var errorFunc = function(err) { + if (err.responseJSON && err.responseJSON.error) { + setFeedbackString(err.responseJSON.error + " (" + err.responseJSON.errcode + ")"); + } + else { + setFeedbackString("Request failed: " + err.status); + } +}; + +var setFeedbackString = function(text) { + $("#feedback").text(text); +}; + matrixRegistration.onLoad = function() { - setupCaptcha(); -}; \ No newline at end of file + setupCaptcha(); +}; + +matrixRegistration.signUp = function() { + var user = $("#desired_user_id").val(); + if (user.length == 0) { + setFeedbackString("Must specify a username."); + return; + } + var pwd1 = $("#pwd1").val(); + var pwd2 = $("#pwd2").val(); + if (pwd1.length < 6) { + setFeedbackString("Password: min. 6 characters."); + return; + } + if (pwd1 != pwd2) { + setFeedbackString("Passwords do not match."); + return; + } + if (window.matrixRegistration.isUsingRecaptcha) { + submitCaptcha(user, pwd1); + } + else { + submitPassword(user, pwd1); + } +}; + +matrixRegistration.onRegistered = function(hs_url, user_id, access_token) { + // clobber this function + console.log("onRegistered - This function should be replaced to proceed."); +}; -- cgit 1.4.1 From 1b4e3b7fa6a6ab1bdfcece1a5288acc3e5d5acbe Mon Sep 17 00:00:00 2001 From: manuroe Date: Tue, 24 Feb 2015 16:16:40 +0100 Subject: Fallback registration page: added the classic viewport meta to fix the display on iPhone Safari and webview. The width of input elements also needs to be fixed. --- static/client/register/index.html | 1 + static/client/register/style.css | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'static/client/register/index.html') diff --git a/static/client/register/index.html b/static/client/register/index.html index d7ed8a1fe7..8c2ed7fbdf 100644 --- a/static/client/register/index.html +++ b/static/client/register/index.html @@ -1,6 +1,7 @@ Registration + diff --git a/static/client/register/style.css b/static/client/register/style.css index d5721c8210..6295619ec4 100644 --- a/static/client/register/style.css +++ b/static/client/register/style.css @@ -18,6 +18,10 @@ a:visited { color: #666; } a:hover { color: #000; } a:active { color: #000; } +input { + width: 100% +} + textarea, input { font-family: inherit; font-size: inherit; @@ -47,6 +51,6 @@ textarea, input { -moz-box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.15); box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.15); - background-color: #f8f8f8; + background-color: #fff800; border: 1px #ccc solid; } \ No newline at end of file -- cgit 1.4.1 From 64c23352f901d1952818425495c4e72f504ce48a Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 24 Feb 2015 16:01:38 +0000 Subject: Use standard form submission so the go button on the keyboard works. --- static/client/register/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'static/client/register/index.html') diff --git a/static/client/register/index.html b/static/client/register/index.html index 8c2ed7fbdf..1650c97116 100644 --- a/static/client/register/index.html +++ b/static/client/register/index.html @@ -9,12 +9,12 @@ -
+
Create account:
- +

@@ -24,7 +24,7 @@
- +
-- cgit 1.4.1 From 4212e7a049b0eeb4d980c848eb3b3aad590cefd1 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 24 Feb 2015 16:02:48 +0000 Subject: tabs/spaces --- static/client/register/index.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'static/client/register/index.html') diff --git a/static/client/register/index.html b/static/client/register/index.html index 1650c97116..600b3ee41e 100644 --- a/static/client/register/index.html +++ b/static/client/register/index.html @@ -10,19 +10,19 @@
-
+
Create account:
- -
- -
- -
+ +
+ +
+ +

-
+
-- cgit 1.4.1