summaryrefslogtreecommitdiff
path: root/users/app/assets
diff options
context:
space:
mode:
Diffstat (limited to 'users/app/assets')
m---------users/app/assets/javascripts/srp0
-rw-r--r--users/app/assets/javascripts/users.js.coffee26
2 files changed, 16 insertions, 10 deletions
diff --git a/users/app/assets/javascripts/srp b/users/app/assets/javascripts/srp
-Subproject efac662cdf31bc4b61ffb97b8c398e22a86c364
+Subproject 076d6e251e4caf826787d87b11434e535960455
diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee
index ab437f6..d0ec32f 100644
--- a/users/app/assets/javascripts/users.js.coffee
+++ b/users/app/assets/javascripts/users.js.coffee
@@ -27,21 +27,27 @@ 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) ->
+ if $.isPlainObject(message) && message.errors
+ for field, error of message.errors
+ element = $('form input[name="session['+field+']"]')
+ next unless element
+ element.trigger('element:validate:fail.ClientSideValidations', error).data('valid', false)
+ else
+ 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