blob: 75440eae2ff014c816e2a7678a822b606e49b6e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
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.loggedIn = ->
window.location = '/'
srp.error = (message) ->
alert(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
|