summaryrefslogtreecommitdiff
path: root/users/app/assets
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-10-02 12:24:44 +0200
committerAzul <azul@leap.se>2012-10-02 12:24:44 +0200
commitf6d6f2d24efceca15caa0858241e0ba1b68cee63 (patch)
tree30287ee481a623cff4914a5cec6b50d45c16b16b /users/app/assets
parentc0f10e15d8d2ec3be620dff62315a44bd065f201 (diff)
bringing sign_up back to life
Diffstat (limited to 'users/app/assets')
-rw-r--r--users/app/assets/javascripts/users.js.coffee41
1 files changed, 41 insertions, 0 deletions
diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee
new file mode 100644
index 0000000..160a7f0
--- /dev/null
+++ b/users/app/assets/javascripts/users.js.coffee
@@ -0,0 +1,41 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
+#
+
+validate_password = (event) ->
+
+ password = $('#srp_password').val()
+ confirmation = $('#srp_password_confirmation').val()
+ login = $('#srp_username').val()
+
+ if password != confirmation
+ alert "Password and Confirmation do not match!"
+ $('#srp_password').focus()
+ return false
+ if password == login
+ alert "Password and Login may not match!"
+ $('#srp_password').focus()
+ return false
+ if password.length < 8
+ alert "Password needs to be at least 8 characters long!"
+ $('#srp_password').focus()
+ return false
+
+ return true
+
+
+insert_verifier = (event) ->
+ # TODO: verify password confimation
+ srp = new SRP
+ salt = srp.session.getSalt()
+ $('#srp_salt').val(salt)
+ $('#srp_password_verifier').val(srp.session.getV().toString(16))
+ # clear the password so we do not submit it
+ $('#srp_password').val('cleared out - use verifier instead')
+ $('#srp_password_confirmation').val('using srp - store verifier')
+
+$(document).ready ->
+ $('#new_user').submit validate_password
+ $('#new_user').submit insert_verifier
+