You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kibble.apache.org by hu...@apache.org on 2017/10/20 18:57:11 UTC
[kibble] 08/12: add signup script, tie it into login.html
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kibble.git
commit ed3b8237aa4f3b7f9b1be93a15507c2f8b66d3dc
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Fri Oct 20 20:40:43 2017 +0200
add signup script, tie it into login.html
---
ui/js/coffee/kibble_account.coffee | 41 +++++++++++++++++++++++++++++++++++++-
ui/login.html | 10 +++++-----
2 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/ui/js/coffee/kibble_account.coffee b/ui/js/coffee/kibble_account.coffee
index 747569d..fe8e773 100644
--- a/ui/js/coffee/kibble_account.coffee
+++ b/ui/js/coffee/kibble_account.coffee
@@ -30,4 +30,43 @@ kibbleLogin = (email, password) ->
signout = () ->
xdelete('session', {}, {}, () -> location.href = 'login.html')
-
\ No newline at end of file
+
+accountCallback = (json, state) ->
+ obj = get('signup')
+ obj.innerHTML = ""
+ h = new HTML('h3', {}, "Account created!")
+ obj.appendChild(h)
+ if json.verified
+ t = new HTML('p', {}, "You can now log in and use your account")
+ else
+ t = new HTML('p', {}, "Please check your email account for a verification email.")
+ obj.appendChild(t)
+
+kibbleSignup = (form) ->
+ email = form.email.value
+ displayName = form.displayname.value
+ password = form.password.value
+ password2 = form.password2.value
+
+ # Passwords must match
+ if password != password2
+ alert("Passwords must match!")
+ return false
+
+ # Username must be >= 2 chars
+ if displayName.length < 2
+ alert("Please enter a proper display name!")
+ return false
+
+ # Email must be valid
+ if not email.match(/([^@]+@[^.]+\.[^.])/)
+ alert("Please enter a valid email address!")
+ return false
+
+ put('account', {
+ email: email,
+ password: password,
+ displayname: displayName
+ }, null, accountCallback)
+
+ return false
\ No newline at end of file
diff --git a/ui/login.html b/ui/login.html
index 2e1167c..c2f6686 100644
--- a/ui/login.html
+++ b/ui/login.html
@@ -39,11 +39,11 @@
</form>
</div>
<div id="signup" class="tab-pane">
- <form action="index.html">
- <input type="email" placeholder="Email address" class="form-control top">
- <input type="text" placeholder="Your full name" class="form-control top">
- <input type="password" placeholder="password" class="form-control middle">
- <input type="password" placeholder="re-password" class="form-control bottom">
+ <form action="index.html" onsubmit="return kibbleSignup(this.elements);">
+ <input name="email" type="email" placeholder="Email address" class="form-control top">
+ <input name="displayname" type="text" placeholder="Your full name" class="form-control top">
+ <input name="password" type="password" placeholder="password" class="form-control middle">
+ <input name="password2" type="password" placeholder="re-password" class="form-control bottom">
<button class="btn btn-lg btn-success btn-block" type="submit">Register</button>
</form>
</div>
--
To stop receiving notification emails like this one, please contact
"commits@kibble.apache.org" <co...@kibble.apache.org>.