From 42cf5141bd7743d16259b0771607ea6a8cbc0fd3 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 15 Oct 2012 11:44:07 +0200 Subject: updated srp_js --- users/app/assets/javascripts/srp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/srp b/users/app/assets/javascripts/srp index d6a7804..6feb770 160000 --- a/users/app/assets/javascripts/srp +++ b/users/app/assets/javascripts/srp @@ -1 +1 @@ -Subproject commit d6a78049f3356d9d645143362eca74434410bf62 +Subproject commit 6feb77060140fe8026812970c4d5ea83da3cd200 -- cgit v1.2.3 From 8841958868fdd11ec49ee6de32ff79f1aa6083fa Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 15 Oct 2012 12:55:03 +0200 Subject: adding login function for srp --- users/app/assets/javascripts/users.js.coffee | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee index 160a7f0..07dbc32 100644 --- a/users/app/assets/javascripts/users.js.coffee +++ b/users/app/assets/javascripts/users.js.coffee @@ -27,7 +27,7 @@ validate_password = (event) -> insert_verifier = (event) -> # TODO: verify password confimation - srp = new SRP + srp = new SRP(jqueryRest()) salt = srp.session.getSalt() $('#srp_salt').val(salt) $('#srp_password_verifier').val(srp.session.getV().toString(16)) @@ -35,7 +35,14 @@ insert_verifier = (event) -> $('#srp_password').val('cleared out - use verifier instead') $('#srp_password_confirmation').val('using srp - store verifier') +login = (event) -> + srp = new SRP(jqueryRest()) + srp.identify() + false + + $(document).ready -> $('#new_user').submit validate_password $('#new_user').submit insert_verifier + $('#new_session').submit login -- cgit v1.2.3 From b85316cc00f53343bc6555b10c79f9aadd86e06f Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 16 Oct 2012 17:29:11 +0200 Subject: working version of srp_js --- users/app/assets/javascripts/srp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/srp b/users/app/assets/javascripts/srp index 6feb770..d21474a 160000 --- a/users/app/assets/javascripts/srp +++ b/users/app/assets/javascripts/srp @@ -1 +1 @@ -Subproject commit 6feb77060140fe8026812970c4d5ea83da3cd200 +Subproject commit d21474a0290edab1c765741d484335d83f50be75 -- cgit v1.2.3 From fdfdc86eb96f670a580eb58b1b3d41560a269ac1 Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 17 Oct 2012 12:39:40 +0200 Subject: improved signup and login js --- users/app/assets/javascripts/srp | 2 +- users/app/assets/javascripts/users.js.coffee | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/srp b/users/app/assets/javascripts/srp index d21474a..5a0ceeb 160000 --- a/users/app/assets/javascripts/srp +++ b/users/app/assets/javascripts/srp @@ -1 +1 @@ -Subproject commit d21474a0290edab1c765741d484335d83f50be75 +Subproject commit 5a0ceeb1ca0055719a9b8977a799362163955766 diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee index 07dbc32..1c00663 100644 --- a/users/app/assets/javascripts/users.js.coffee +++ b/users/app/assets/javascripts/users.js.coffee @@ -25,24 +25,20 @@ validate_password = (event) -> return true -insert_verifier = (event) -> - # TODO: verify password confimation +signup = (event) -> srp = new SRP(jqueryRest()) - 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') + srp.register() + false login = (event) -> srp = new SRP(jqueryRest()) - srp.identify() + srp.identify -> + window.location = '/' false $(document).ready -> $('#new_user').submit validate_password - $('#new_user').submit insert_verifier + $('#new_user').submit signup $('#new_session').submit login -- cgit v1.2.3 From 3ba2e664a26e96a93c8640b57241af6386db361e Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 19 Oct 2012 18:03:37 +0200 Subject: login after signup right away. --- users/app/assets/javascripts/srp | 2 +- users/app/assets/javascripts/users.js.coffee | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/srp b/users/app/assets/javascripts/srp index 5a0ceeb..23350b5 160000 --- a/users/app/assets/javascripts/srp +++ b/users/app/assets/javascripts/srp @@ -1 +1 @@ -Subproject commit 5a0ceeb1ca0055719a9b8977a799362163955766 +Subproject commit 23350b54ec2723e1b2e333626567c9fe9d1e2644 diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee index 1c00663..24302fe 100644 --- a/users/app/assets/javascripts/users.js.coffee +++ b/users/app/assets/javascripts/users.js.coffee @@ -27,7 +27,8 @@ validate_password = (event) -> signup = (event) -> srp = new SRP(jqueryRest()) - srp.register() + srp.register -> + window.location = '/' false login = (event) -> -- cgit v1.2.3 From cf1e7ee20f713068cadf5cfa78840115e0a8a081 Mon Sep 17 00:00:00 2001 From: Azul Date: Sun, 4 Nov 2012 16:28:58 +0100 Subject: using ruby-srp 0.1.4 - ruby 1.9.3 compatible --- users/app/assets/javascripts/srp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/srp b/users/app/assets/javascripts/srp index 23350b5..d6a7804 160000 --- a/users/app/assets/javascripts/srp +++ b/users/app/assets/javascripts/srp @@ -1 +1 @@ -Subproject commit 23350b54ec2723e1b2e333626567c9fe9d1e2644 +Subproject commit d6a78049f3356d9d645143362eca74434410bf62 -- cgit v1.2.3 From e04dc9ab8b9f1aaaf75f327ef4fd0f7f4d755a12 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 6 Nov 2012 11:55:18 +0100 Subject: undo accidentally reverted srp-js and ruby 1.9 debugger in gemfile --- users/app/assets/javascripts/srp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/srp b/users/app/assets/javascripts/srp index d6a7804..3bf101b 160000 --- a/users/app/assets/javascripts/srp +++ b/users/app/assets/javascripts/srp @@ -1 +1 @@ -Subproject commit d6a78049f3356d9d645143362eca74434410bf62 +Subproject commit 3bf101bc1ef3b5a58fe2f1e2a2e7a681f6de6c09 -- cgit v1.2.3 From ca2e1b9f379ccba068ad0ebb852d855f1639cd3a Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 9 Nov 2012 15:07:16 +0100 Subject: merged srp master into json api branch --- users/app/assets/javascripts/srp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/srp b/users/app/assets/javascripts/srp index 3bf101b..efac662 160000 --- a/users/app/assets/javascripts/srp +++ b/users/app/assets/javascripts/srp @@ -1 +1 @@ -Subproject commit 3bf101bc1ef3b5a58fe2f1e2a2e7a681f6de6c09 +Subproject commit efac662cdf31bc4b61ffb97b8c398e22a86c364b -- cgit v1.2.3 From 67dc2685a72c125b53f351c3a75bf812123e96bd Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 12 Nov 2012 13:03:13 +0100 Subject: fixed signup bug and refactored a bit --- users/app/assets/javascripts/users.js.coffee | 51 ++++++++++++++++------------ 1 file changed, 29 insertions(+), 22 deletions(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee index 24302fe..8a9f0e9 100644 --- a/users/app/assets/javascripts/users.js.coffee +++ b/users/app/assets/javascripts/users.js.coffee @@ -3,43 +3,50 @@ # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ # -validate_password = (event) -> +preventDefault = (event) -> + event.preventDefault() - 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 +validOrAbort = (event) -> + errors = {} + + abortIfErrors = -> + return if $.isEmptyObject(errors) + $.each errors, (field, error) -> + alert(error) + $('#srp_password').focus() + event.stopImmediatePropagation() + + validatePassword = -> + password = $('#srp_password').val() + confirmation = $('#srp_password_confirmation').val() + login = $('#srp_username').val() + + if password != confirmation + errors.password_confirmation = "Confirmation does not match!" + if password == login + errors.password = "Password and Login may not match!" + if password.length < 8 + errors.password = "Password needs to be at least 8 characters long!" + + validatePassword() + abortIfErrors() - return true - signup = (event) -> srp = new SRP(jqueryRest()) srp.register -> window.location = '/' - false login = (event) -> srp = new SRP(jqueryRest()) srp.identify -> window.location = '/' - false $(document).ready -> - $('#new_user').submit validate_password + $('#new_user').submit preventDefault + $('#new_user').submit validOrAbort $('#new_user').submit signup + $('#new_session').submit preventDefault $('#new_session').submit login -- cgit v1.2.3 From 6ba3366f778340ebeaa73fd53372368b16de6c98 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 13 Nov 2012 12:00:13 +0100 Subject: using client side validations during signup --- users/app/assets/javascripts/users.js.coffee | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee index 8a9f0e9..ab437f6 100644 --- a/users/app/assets/javascripts/users.js.coffee +++ b/users/app/assets/javascripts/users.js.coffee @@ -1,8 +1,3 @@ -# 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/ -# - preventDefault = (event) -> event.preventDefault() @@ -11,9 +6,9 @@ validOrAbort = (event) -> abortIfErrors = -> return if $.isEmptyObject(errors) - $.each errors, (field, error) -> - alert(error) - $('#srp_password').focus() + # we're relying on client_side_validations here instead of printing + # our own errors. This gets us translatable error messages. + $('.control-group.error input, .control-group.error select, control-group.error textarea').first().focus() event.stopImmediatePropagation() validatePassword = -> -- cgit v1.2.3 From 7e5db2a28ba872154e5f5002bb84d149a512e36e Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 22 Nov 2012 10:33:21 +0100 Subject: using the new srp.js api --- users/app/assets/javascripts/srp | 2 +- users/app/assets/javascripts/users.js.coffee | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/srp b/users/app/assets/javascripts/srp index efac662..635ea47 160000 --- a/users/app/assets/javascripts/srp +++ b/users/app/assets/javascripts/srp @@ -1 +1 @@ -Subproject commit efac662cdf31bc4b61ffb97b8c398e22a86c364b +Subproject commit 635ea47f1c19d7985a8f5107c070ae19edf9dd54 diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee index ab437f6..75440ea 100644 --- a/users/app/assets/javascripts/users.js.coffee +++ b/users/app/assets/javascripts/users.js.coffee @@ -27,21 +27,21 @@ validOrAbort = (event) -> abortIfErrors() -signup = (event) -> - srp = new SRP(jqueryRest()) - srp.register -> - window.location = '/' -login = (event) -> - srp = new SRP(jqueryRest()) - srp.identify -> - window.location = '/' +srp.session = new srp.Session() +srp.signedUp = -> + window.location = '/' +srp.loggedIn = -> + window.location = '/' + +srp.error = (message) -> + alert(message) $(document).ready -> $('#new_user').submit preventDefault $('#new_user').submit validOrAbort - $('#new_user').submit signup + $('#new_user').submit srp.signup $('#new_session').submit preventDefault - $('#new_session').submit login + $('#new_session').submit srp.login -- cgit v1.2.3 From cec9ad7c514f2f3c767bd12bfc3df28db4d1a98b Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 22 Nov 2012 11:36:25 +0100 Subject: using client side validations for login --- users/app/assets/javascripts/users.js.coffee | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee index 75440ea..6d1dda2 100644 --- a/users/app/assets/javascripts/users.js.coffee +++ b/users/app/assets/javascripts/users.js.coffee @@ -36,7 +36,13 @@ srp.loggedIn = -> window.location = '/' srp.error = (message) -> - alert(message) + if $.isPlainObject(message) && message.errors + for key, value of message.errors + element = $('form input[name="session['+key+']"]') + next unless element + element.trigger('element:validate:fail.ClientSideValidations', value).data('valid', false) + else + alert(message) $(document).ready -> $('#new_user').submit preventDefault -- cgit v1.2.3 From 6d5f8d0f993093b51d1f11bb528c535dcf88a969 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 22 Nov 2012 13:05:32 +0100 Subject: beautify login workflow * translating error messages * not caching login and password in js anymore * catching non responses --- users/app/assets/javascripts/srp | 2 +- users/app/assets/javascripts/users.js.coffee | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/srp b/users/app/assets/javascripts/srp index 635ea47..076d6e2 160000 --- a/users/app/assets/javascripts/srp +++ b/users/app/assets/javascripts/srp @@ -1 +1 @@ -Subproject commit 635ea47f1c19d7985a8f5107c070ae19edf9dd54 +Subproject commit 076d6e251e4caf826787d87b11434e535960455c diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee index 6d1dda2..d0ec32f 100644 --- a/users/app/assets/javascripts/users.js.coffee +++ b/users/app/assets/javascripts/users.js.coffee @@ -37,10 +37,10 @@ srp.loggedIn = -> srp.error = (message) -> if $.isPlainObject(message) && message.errors - for key, value of message.errors - element = $('form input[name="session['+key+']"]') + for field, error of message.errors + element = $('form input[name="session['+field+']"]') next unless element - element.trigger('element:validate:fail.ClientSideValidations', value).data('valid', false) + element.trigger('element:validate:fail.ClientSideValidations', error).data('valid', false) else alert(message) -- cgit v1.2.3 From 76a3b91ad78d12ef82a0c01ca702720a510f1e22 Mon Sep 17 00:00:00 2001 From: Azul Date: Sun, 25 Nov 2012 13:21:23 +0100 Subject: basic changing of password and login working --- users/app/assets/javascripts/srp | 2 +- users/app/assets/javascripts/users.js.coffee | 36 ++++++---------------------- 2 files changed, 8 insertions(+), 30 deletions(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/srp b/users/app/assets/javascripts/srp index 076d6e2..fff770a 160000 --- a/users/app/assets/javascripts/srp +++ b/users/app/assets/javascripts/srp @@ -1 +1 @@ -Subproject commit 076d6e251e4caf826787d87b11434e535960455c +Subproject commit fff770a866b44abce6fe0fc5d5ffde034225436d diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee index d0ec32f..5663161 100644 --- a/users/app/assets/javascripts/users.js.coffee +++ b/users/app/assets/javascripts/users.js.coffee @@ -1,40 +1,17 @@ preventDefault = (event) -> event.preventDefault() -validOrAbort = (event) -> - errors = {} - - abortIfErrors = -> - return if $.isEmptyObject(errors) - # we're relying on client_side_validations here instead of printing - # our own errors. This gets us translatable error messages. - $('.control-group.error input, .control-group.error select, control-group.error textarea').first().focus() - event.stopImmediatePropagation() - - validatePassword = -> - password = $('#srp_password').val() - confirmation = $('#srp_password_confirmation').val() - login = $('#srp_username').val() - - if password != confirmation - errors.password_confirmation = "Confirmation does not match!" - if password == login - errors.password = "Password and Login may not match!" - if password.length < 8 - errors.password = "Password needs to be at least 8 characters long!" - - validatePassword() - abortIfErrors() - - - srp.session = new srp.Session() srp.signedUp = -> - window.location = '/' + srp.login srp.loggedIn = -> window.location = '/' +#// TODO: not sure this is what we want. +srp.updated = -> + window.location = '/' + srp.error = (message) -> if $.isPlainObject(message) && message.errors for field, error of message.errors @@ -46,8 +23,9 @@ srp.error = (message) -> $(document).ready -> $('#new_user').submit preventDefault - $('#new_user').submit validOrAbort $('#new_user').submit srp.signup $('#new_session').submit preventDefault $('#new_session').submit srp.login + $('.user.form.edit').submit srp.update + $('.user.form.edit').submit preventDefault -- cgit v1.2.3 From ce0999ead0d61db1f6534ee9d8114c4551542e80 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 26 Nov 2012 10:59:50 +0100 Subject: minor: client side validations fixed + .json request --- users/app/assets/javascripts/users.js.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee index 5663161..f0bb3dd 100644 --- a/users/app/assets/javascripts/users.js.coffee +++ b/users/app/assets/javascripts/users.js.coffee @@ -15,7 +15,7 @@ srp.updated = -> srp.error = (message) -> if $.isPlainObject(message) && message.errors for field, error of message.errors - element = $('form input[name="session['+field+']"]') + element = $('form input[name$="['+field+']"]') next unless element element.trigger('element:validate:fail.ClientSideValidations', error).data('valid', false) else -- cgit v1.2.3 From 51ba799f98113b7112f2968fc80e4d291924b3bf Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 26 Nov 2012 16:34:46 +0100 Subject: basic users index with typeahead search --- users/app/assets/javascripts/users.js.coffee | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee index f0bb3dd..61d4121 100644 --- a/users/app/assets/javascripts/users.js.coffee +++ b/users/app/assets/javascripts/users.js.coffee @@ -21,6 +21,9 @@ srp.error = (message) -> else alert(message) +pollUsers = (query, process) -> + $.get( "/users.json", query: query).done(process); + $(document).ready -> $('#new_user').submit preventDefault $('#new_user').submit srp.signup @@ -28,4 +31,5 @@ $(document).ready -> $('#new_session').submit srp.login $('.user.form.edit').submit srp.update $('.user.form.edit').submit preventDefault + $('.user.typeahead').typeahead({source: pollUsers}); -- cgit v1.2.3 From a941c89293bcbb067c6152b63765ead38a484b81 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 26 Nov 2012 18:06:21 +0100 Subject: basic typeahead and user querying working --- users/app/assets/javascripts/users.js.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'users/app/assets/javascripts') diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee index 61d4121..76a6d79 100644 --- a/users/app/assets/javascripts/users.js.coffee +++ b/users/app/assets/javascripts/users.js.coffee @@ -22,7 +22,7 @@ srp.error = (message) -> alert(message) pollUsers = (query, process) -> - $.get( "/users.json", query: query).done(process); + $.get( "/users.json", query: query).done(process) $(document).ready -> $('#new_user').submit preventDefault -- cgit v1.2.3