aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2014-09-03 14:34:22 -0700
committerAdam Soltys <[email protected]>2014-09-03 14:34:22 -0700
commitcd55bb01756ba97fe808c5818e29b0a516737afb (patch)
treebc2b093464e58a5b4a1f40e163c29351f9dda0e5
parent2f65c2ad5d2c4b9fd2ec143aedf60cce01eef660 (diff)
downloadcoinos-server-cd55bb01756ba97fe808c5818e29b0a516737afb.tar.gz
coinos-server-cd55bb01756ba97fe808c5818e29b0a516737afb.zip
Separate account profile settings
-rw-r--r--public/css/calculator.less3
-rw-r--r--public/js/calculator.coffee12
-rw-r--r--public/js/profile.coffee130
-rw-r--r--public/js/setup.coffee10
-rw-r--r--routes/users.js6
-rw-r--r--src/routes/users.coffee6
-rw-r--r--views/layout.html6
-rw-r--r--views/transactions/index.html2
-rw-r--r--views/users/edit.html13
-rw-r--r--views/users/profile.html6
-rw-r--r--views/users/show.html8
11 files changed, 32 insertions, 170 deletions
diff --git a/public/css/calculator.less b/public/css/calculator.less
index 23b729d2..2764332b 100644
--- a/public/css/calculator.less
+++ b/public/css/calculator.less
@@ -29,10 +29,11 @@ div.container-fluid {
p, span, .form-control { font-size: 18px; }
span, label { color: #999; }
.form-control { height: auto; padding: 3px; display: inline-block; }
+ .input-group-addon { color: #000; }
}
div#calculator {
- #exchange, #amount { width: 5em; }
+ #amount { width: 5em; }
#received { font-size: 16px; width: 100%; }
strong#total { font-size: 30px; }
p#address { padding-top: 10px; }
diff --git a/public/js/calculator.coffee b/public/js/calculator.coffee
index 64a26a65..edbd4fa9 100644
--- a/public/js/calculator.coffee
+++ b/public/js/calculator.coffee
@@ -54,14 +54,15 @@ setup = ->
g.user.symbol or= 'quadrigacx'
g.user.unit or= 'BTC'
+ if g.user.title
+ $('#title').html("<a href='/#{g.user.username}/edit'>#{g.user.title}</a>").show()
+
if g.user.logo
$('#logo').attr('src', g.user.logo).show()
- else if g.user.title
- $('#title').html("<a href='/#{g.user.username}/edit'>#{g.user.title}</a>").show()
getAddress() if g.user.bip32
- $('#symbol').html(g.user.symbol + " bid")
+ $('#symbol').html(g.user.currency)
$('#currency').html(g.user.currency)
$('#unit').html(g.user.unit)
$('#received').hide()
@@ -80,8 +81,8 @@ fetchExchangeRate = ->
fail(EXCHANGE_FAIL)
return
- g.exchange = exchange - exchange * g.user.commission * 0.01
- $('#exchange').val(g.exchange.toFixed(2))
+ g.exchange = (exchange - exchange * g.user.commission * 0.01).toFixed(2)
+ $('#exchange').html(g.exchange)
updateTotal()
unless g.setupComplete
@@ -232,6 +233,7 @@ multiplier = ->
when 'BTC' then 1
when 'mBTC' then 1000
when 'µBTC' then 1000000
+ when 'bits' then 1000000
when 'satoshis' then 100000000
diff --git a/public/js/profile.coffee b/public/js/profile.coffee
index 1e929d60..ee42bf19 100644
--- a/public/js/profile.coffee
+++ b/public/js/profile.coffee
@@ -10,82 +10,11 @@ $(->
user = $('#username').val()
$.getJSON("/#{user}.json", (data) ->
- $('#username').val(data.title)
- $('#email').val(data.logo)
+ $('#username').val(data.username)
+ $('#email').val(data.email)
$('#profile').fadeIn()
)
- units = ['BTC', 'mBTC', '&micro;BTC', 'satoshis']
- $.each(units, (i, v) ->
- $('#unit').append("<option value='#{v}'>#{v}</option>")
- )
-
- $('#title').blur(->
- if $(this).val() == '' and $('#logo').val() == ''
- $(this).parent().addClass('has-error')
- else
- $(this).parent().removeClass('has-error')
- )
-
- $('#bip32').blur(->
- try
- new BIP32($(this).val())
- $(this).parent().removeClass('has-error')
- catch
- $(this).parent().addClass('has-error')
- )
-
- $('#generate').click(->
- rng = new SecureRandom()
- bytes = new Array(256)
- rng.nextBytes(bytes)
-
- hasher = new jsSHA(bytes.toString(), 'TEXT')
- rng.nextBytes(bytes)
-
- I = hasher.getHMAC(bytes.toString(), "TEXT", "SHA-512", "HEX")
- il = Crypto.util.hexToBytes(I.slice(0, 64))
- ir = Crypto.util.hexToBytes(I.slice(64, 128))
-
- key = new BIP32()
- key.eckey = new Bitcoin.ECKey(il)
- key.eckey.pub = key.eckey.getPubPoint()
- key.eckey.setCompressed(true)
- key.eckey.pubKeyHash = Bitcoin.Util.sha256ripe160(key.eckey.pub.getEncoded(true))
- key.has_private_key = true
-
- key.chain_code = ir
- key.child_index = 0
- key.parent_fingerprint = Bitcoin.Util.hexToBytes("00000000")
- key.version = BITCOIN_MAINNET_PRIVATE
- key.depth = 0
-
- key.build_extended_public_key()
- key.build_extended_private_key()
-
- g.pubkey = key.extended_public_key_string()
- g.privkey = key.extended_private_key_string()
-
- $('#modal').modal()
- $('#privkey').html(g.privkey)
- $('#qr').html('')
- new QRCode('qr', text: g.privkey, width: 260, height: 260)
- )
-
- $('#encryption-password').keyup((e) ->
- return if e.keyCode is 9 or e.keyCode is 16
- enc_privkey = CryptoJS.AES.encrypt(g.privkey, $(this).val()).toString()
- enc_privkey = g.privkey if $(this).val() == ''
- $('#privkey').html(enc_privkey)
- $('#qr').html('')
- new QRCode('qr', text: enc_privkey, width: 260, height: 260)
-
- if $(this).val()
- $('#status').html('(Encrypted)')
- else
- $('#status').html('(Unencrypted Plaintext)')
- )
-
$('#confirm').blur(->
$('#confirm_error').remove()
if $('#password').val() != $('#confirm').val()
@@ -95,57 +24,10 @@ $(->
$('#password, #confirm').parent().removeClass('has-error')
)
- $('#encryption-password, #encryption-confirm').keyup((e) -> check_passwords(e) unless e.keyCode is 9)
- $('#encryption-password, #encryption-confirm').blur((e) -> check_passwords(e))
-
- check_passwords = (e) ->
- if $('#encryption-password').val() != $('#encryption-confirm').val() or $('#encryption-password').val() is ''
- $('#encryption-password, #encryption-confirm').parent().addClass('has-error')
- $('#modal .alert').removeClass('alert-success').addClass('alert-danger')
- else
- $('#encryption-password, #encryption-confirm').parent().removeClass('has-error')
- $('#modal .alert').removeClass('alert-danger').addClass('alert-success')
-
- $('#print').click(->
- $('#key-dialog').printElement(printMode: 'popup')
- )
-
- $('a[data-toggle="tab"]').on('shown.bs.tab', (e) ->
- $('#encryption-password').focus()
- switch e.target.attributes.href.value
- when '#step1'
- $('.modal-footer button:first').hide()
- $('.modal-footer button:last').html('Next').off().on('click', -> $('a[data-toggle="tab"]:eq(1)').click())
- when '#step2'
- $('.modal-footer button:first').show().html('Back').off().on('click', -> $('a[data-toggle="tab"]:eq(0)').click())
- $('.modal-footer button:last').html('Next').off().on('click', -> $('a[data-toggle="tab"]:eq(2)').click())
- when '#step3'
- $('.modal-footer button:first').show().html('Back').off().on('click', -> $('a[data-toggle="tab"]:eq(1)').click())
- $('.modal-footer button:last').html('Got it!').off().on('click', ->
- $('#modal .form-control').blur()
- if $('#modal .has-error').length > 0
- $('a[data-toggle="tab"]:eq(1)').click()
- $('#modal .has-error').effect('shake', 500)
- else
- g.update_pub_key = true
- $('#modal').modal('hide')
- )
- )
-
- $('.modal-footer button:last').on('click', -> $('a[data-toggle="tab"]:eq(1)').click())
- $('#modal').on('shown.bs.modal', ->
- g.update_pub_key = false
- $('#encryption-password, #encryption-confirm').val('').blur()
- if $('.tab-pane:eq(2)').hasClass('active')
- $('a[data-toggle="tab"]:eq(1)').click()
- ).on('hidden.bs.modal', ->
- $('#bip32').val(g.pubkey) if g.update_pub_key
- )
-
- $('#setup').submit(->
- $('#setup .form-control').blur()
- if $('#setup .has-error').length > 0
- $('#setup .has-error').effect('shake', 500)
+ $('#profile').submit(->
+ $('#profile .form-control').blur()
+ if $('#profile .has-error').length > 0
+ $('#profile .has-error').effect('shake', 500)
return false
)
)
diff --git a/public/js/setup.coffee b/public/js/setup.coffee
index fdba60df..272e2159 100644
--- a/public/js/setup.coffee
+++ b/public/js/setup.coffee
@@ -20,9 +20,6 @@ g = exports ? this
g.proceed = false
$(->
- $('[data-toggle=popover]').popover()
- $('#title').focus()
-
$.getJSON("/js/rates.json", (data) ->
currencies = Object.keys(data)
currencies = currencies.sort()
@@ -39,7 +36,8 @@ $(->
return unless symbol
symbols = Object.keys(data[symbol])
$.each(symbols, (i, v) ->
- $('#symbol').append("<option value='#{v}'>#{v} bid price</option>")
+ return if v == 'localbitcoins'
+ $('#symbol').append("<option value='#{v}'>#{v}</option>")
)
switch $(this).val()
@@ -60,10 +58,11 @@ $(->
$('#unit').val(data.unit)
$('#currency').change()
$('#setup').fadeIn()
+ $('#title').focus()
)
)
- units = ['BTC', 'mBTC', '&micro;BTC', 'satoshis']
+ units = ['BTC', 'mBTC', '&micro;BTC', 'bits', 'satoshis']
$.each(units, (i, v) ->
$('#unit').append("<option value='#{v}'>#{v}</option>")
)
@@ -196,4 +195,5 @@ $(->
$('#setup .has-error').effect('shake', 500)
return false
)
+
)
diff --git a/routes/users.js b/routes/users.js
index ad3fa165..b555f026 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -170,9 +170,7 @@
delete req.body.password;
}
return db.hmset("user:" + req.params.user, req.body, function() {
- if (req.body.password == null) {
- return res.redirect("/" + req.params.user);
- } else {
+ if (req.body.password != null) {
return bcrypt.hash(req.body.password, 12, function(err, hash) {
return db.hmset("user:" + req.params.user, {
password: hash
@@ -180,6 +178,8 @@
return res.redirect("/" + req.params.user);
});
});
+ } else {
+ return res.redirect("/" + req.params.user);
}
});
},
diff --git a/src/routes/users.coffee b/src/routes/users.coffee
index 88379884..c911fea5 100644
--- a/src/routes/users.coffee
+++ b/src/routes/users.coffee
@@ -127,14 +127,14 @@ module.exports = (sessions) ->
if req.body.password is ''
delete req.body.password
db.hmset("user:"+req.params.user, req.body, ->
- if not req.body.password?
- res.redirect("/#{req.params.user}")
- else
+ if req.body.password?
bcrypt.hash(req.body.password, 12, (err, hash) ->
db.hmset("user:"+req.params.user,password: hash, ->
res.redirect("/#{req.params.user}")
)
)
+ else
+ res.redirect("/#{req.params.user}")
)
verify: (req, res) ->
diff --git a/views/layout.html b/views/layout.html
index 0601ce1f..5be45ded 100644
--- a/views/layout.html
+++ b/views/layout.html
@@ -19,12 +19,10 @@
<div id="nav" class="collapse navbar-collapse">
<div class="navbar">
<ul class="nav navbar-nav">
- <!--
- <li><a href="{{user}}/edit"><span class="glyphicon glyphicon-user"></span> Profile</a></li>
--->
<li><a href="/{{user}}"><span class="glyphicon glyphicon-home"></span> Home</a></li>
- <li><a href="/{{user}}/edit"><span class="glyphicon glyphicon-cog"></span> Settings</a></li>
<li><a href="/{{user}}/report"><span class="glyphicon glyphicon-list-alt"></span> Transactions</a></li>
+ <li><a href="/{{user}}/profile"><span class="glyphicon glyphicon-user"></span> Account Profile</a></li>
+ <li><a href="/{{user}}/edit"><span class="glyphicon glyphicon-cog"></span> Settings</a></li>
<li><a href="/logout"><span class="glyphicon glyphicon-off"></span> Logout</a></li>
<!--
<li><a href="/help"><span class="glyphicon glyphicon-info-sign"></span> Help</a></li>
diff --git a/views/transactions/index.html b/views/transactions/index.html
index dcb76580..d48d28f1 100644
--- a/views/transactions/index.html
+++ b/views/transactions/index.html
@@ -2,7 +2,7 @@
{{#js}}js/report{{/js}}
{{/yield-scripts}}
-<h1>Transactions</h1>
+<h1>Payments Received</h1>
<div style="margin-bottom: 15px">
<input id="user" type="hidden" value="{{user}}" />
diff --git a/views/users/edit.html b/views/users/edit.html
index dda4fef4..a4ba131d 100644
--- a/views/users/edit.html
+++ b/views/users/edit.html
@@ -40,7 +40,7 @@
</div>
<div class="form-group">
- <label for="commission">Commission/Discount <small>(optional %)</small>:</label>
+ <label for="commission">Commission / Discount:</label>
<input type="text" id="commission" name="commission" class="form-control" />
</div>
@@ -50,17 +50,6 @@
</select>
</div>
- <div class="form-group">
- <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 />
<input class="btn btn-primary" type="submit" value="Done" />
</form>
diff --git a/views/users/profile.html b/views/users/profile.html
index 048b11fb..6d05d61d 100644
--- a/views/users/profile.html
+++ b/views/users/profile.html
@@ -3,7 +3,7 @@
{{/yield-scripts}}
<form id="profile" action="/{{user}}" method="post" style="display: none">
- <h1>Profile</h1>
+ <h1>Account Profile</h1>
<div class="form-group">
<label for="username">Username:</label>
@@ -29,7 +29,3 @@
<input class="btn btn-primary" type="submit" value="Done" />
</form>
-<div class="jumbotron">
- <h3>Wallet Balance</h3>
- <h1>0.01982001</h1>
-</div>
diff --git a/views/users/show.html b/views/users/show.html
index 2db57008..fd5afd49 100644
--- a/views/users/show.html
+++ b/views/users/show.html
@@ -17,15 +17,9 @@ Your email has been verified. Thank you!
<form role="form">
<div class="form-group">
- <label for="exchange">Rate:</label>
- <input type="text" id="exchange" value="0" disabled class="form-control" />
- <span id="symbol"></span>
- </div>
-
- <div class="form-group">
<label for="amount">Amount:</label>
<input type="text" id="amount" class="form-control" />
- <span id="currency"></span>
+ <span id="currency"></span> / <span id="exchange"></span> <span>BTC</span>
</div>
<div class="form-group">