aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--public/css/calculator.less8
-rw-r--r--public/js/setup.coffee18
-rw-r--r--routes/users.coffee9
-rw-r--r--views/calculator/setup.html9
-rw-r--r--views/users/new.html10
5 files changed, 44 insertions, 10 deletions
diff --git a/public/css/calculator.less b/public/css/calculator.less
index be8a7e7d..2b7ffc92 100644
--- a/public/css/calculator.less
+++ b/public/css/calculator.less
@@ -17,15 +17,14 @@ div.container-fluid {
.form-group {
.form-control { height: 40px; padding: 3px; }
- label { font-weight: normal; display: block; }
- p, span, input[type="text"], select, label { font-size: 20px; }
+ label { font-weight: normal; font-size: 14px; display: block; }
+ p, span, input[type="text"], select { font-size: 18px; }
span, label { color: #999; }
.form-control { display: inline-block; }
}
form#setup, form#register {
- .form-control { width: 300px; }
- #address { font-size: 12px; }
+ .form-control { width: 400px; }
}
@@ -39,7 +38,6 @@ div#calculator {
}
td#total { font-weight: bold; text-align: right; }
-small { color: #999; }
div#calculator p#address { font-size: 1em; margin-top: 20px; }
diff --git a/public/js/setup.coffee b/public/js/setup.coffee
index dcb58bcb..e8b4e09b 100644
--- a/public/js/setup.coffee
+++ b/public/js/setup.coffee
@@ -4,19 +4,20 @@
#= require jsbn2.js
#= require check_address.js
+g = exports ? this
+g.proceed = false
+
$(->
$.getJSON("/js/rates.json", (data) ->
currencies = Object.keys(data)
currencies = currencies.sort()
currencies.pop()
-
$.each(currencies, (i, v) ->
$('#currency').append("<option value='#{v}'>#{v}</option>")
)
$("#currency option[value='CAD']").attr('selected', 'selected')
-
user = $('#username').val()
$('#currency').change(->
@@ -41,6 +42,19 @@ $(->
$(this).css('color', 'red')
)
+ $('#confirm').blur(->
+ $('#confirm_error').remove()
+ if $('#password').val() != $('#confirm').val()
+ $('#password, #confirm').parent().addClass('has-error')
+ $('#confirm').parent().after('<div id="confirm_error" class="alert alert-danger">Passwords don\'t match</div>')
+ else
+ $('#password, #confirm').parent().removeClass('has-error')
+ )
+
+ $('#setup').submit(->
+ return false if $('.has-error').length()
+ )
+
if user
$('#setup').attr('action', "/#{user}/update").attr('method', 'post')
$.getJSON("/#{user}.json", (data) ->
diff --git a/routes/users.coffee b/routes/users.coffee
index 04284d5a..beae3eb0 100644
--- a/routes/users.coffee
+++ b/routes/users.coffee
@@ -53,11 +53,20 @@ module.exports = (sessions) ->
)
create: (req, res) ->
+ errormsg = ""
userkey = "user:"+req.body.username
db.hgetall(userkey, (err, obj) ->
if obj
res.redirect(req.body.username)
else
+ if req.body.confirm != req.body.password
+ errormsg += "Passwords must match"
+ return res.render('users/new',
+ js: (-> global.js),
+ css: (-> global.css),
+ error: errormsg
+ )
+
bcrypt.hash(req.body.password, 12, (err, hash) ->
db.sadd("users",userkey)
db.hmset(userkey,
diff --git a/views/calculator/setup.html b/views/calculator/setup.html
index e125eea9..26977c7a 100644
--- a/views/calculator/setup.html
+++ b/views/calculator/setup.html
@@ -48,8 +48,13 @@
</div>
<div class="form-group">
- <label for="password">Password <small>(blank = no change)</small>:</label>
- <input type="text" id="password" name="password" class="form-control" />
+ <label for="password">New Password <small>(blank = no change)</small>:</label>
+ <input type="password" id="password" name="password" class="form-control" />
+ </div>
+
+ <div class="form-group">
+ <label for="confirm">Confirm New Password:</label>
+ <input type="password" id="confirm" name="confirm" class="form-control" />
</div>
<br />
diff --git a/views/users/new.html b/views/users/new.html
index 258e8119..e9874217 100644
--- a/views/users/new.html
+++ b/views/users/new.html
@@ -6,12 +6,15 @@
<title>Bitcoin Payment Calculator</title>
<link href="img/favicon.ico" rel="shortcut icon" />
{{#css}}calculator{{/css}}
- {{#js}}setup{{/js}}
+ {{#js}}register{{/js}}
</head>
<body>
<div class="container-fluid">
<form id="register" action="/users" method="post">
<h1>Register</h1>
+ {{#error}}
+ <div class="alert alert-danger">{{error}}</div>
+ {{/error}}
<div class="form-group">
<label for="username">Username:</label>
<input type="text" id="username" name="username" class="form-control" />
@@ -21,6 +24,11 @@
<label for="password">Password:</label>
<input type="password" id="password" name="password" class="form-control" />
</div>
+
+ <div class="form-group">
+ <label for="confirm">Confirm Password:</label>
+ <input type="password" id="confirm" name="confirm" class="form-control" />
+ </div>
<div class="form-group">
<label for="email">Email:</label>