diff options
| -rw-r--r-- | app.coffee | 71 | ||||
| -rw-r--r-- | public/img/adam.jpg | bin | 0 -> 18488 bytes | |||
| -rw-r--r-- | public/img/jackson.jpg | bin | 0 -> 8130 bytes | |||
| -rw-r--r-- | public/img/yuri.jpg | bin | 0 -> 4380 bytes | |||
| -rw-r--r-- | views/about.html | 8 | ||||
| -rw-r--r-- | views/exchangers.html | 35 | ||||
| -rw-r--r-- | views/layout.html | 2 | ||||
| -rw-r--r-- | views/user.html | 43 |
8 files changed, 114 insertions, 45 deletions
@@ -5,14 +5,9 @@ engines = require('consolidate') passport = require('passport') bcrypt = require('bcrypt') db = require("redis").createClient() -app = express() +ask = bid = 0 LocalStrategy = require('passport-local').Strategy -passport.use(new LocalStrategy( - (username, password, done) -> - user = username: 'soltysa', password: 'adam' - return done(null, user) -)) passport.serializeUser((user, done) -> done(null, user.username) @@ -23,6 +18,29 @@ passport.deserializeUser((id, done) -> done(null, user) ) +passport.use(new LocalStrategy( + (username, password, done) -> + bcrypt.hash(password, 12, (err, hash) -> + db.hget(username, 'password', (err, result) -> + console.log(result) + if result + bcrypt.compare(password, result, (err, match) -> + console.log(match) + if match + db.hgetall(username, (err, user) -> + return done(null, user) + ) + ) + ) + ) + return done(null, false) +)) + +ensureAuthenticated = (req, res, next) -> + return next() if req.isAuthenticated() + res.redirect('/login') + +app = express() app.enable('trust proxy') app.engine('html', require('mmm').__express) app.set('view engine', 'html') @@ -45,11 +63,14 @@ routes = "/merchants/signup": 'signup' "/contact": 'contact' - for route, view of routes ((route, view) -> app.get(route, (req, res) -> - res.render(view, js: (-> global.js), css: (-> global.css), layout: 'layout') + res.render(view, + js: (-> global.js), + css: (-> global.css), + layout: 'layout' + ) ) )(route, view) @@ -96,7 +117,7 @@ app.get('/ticker', (req, res) -> host: 'bitcoincharts.com', path: "/t/depthcalc.json?symbol=#{req.query.symbol}&type=#{req.query.type}&amount=#{req.query.amount}¤cy=true" - require('http').get(options, (r) -> + http.get(options, (r) -> r.setEncoding('utf-8') r.on('data', (chunk) -> try @@ -136,28 +157,6 @@ app.post('/login', (req, res, next) -> ) app.post('/users', (req, res) -> - if req.body.login - if req.body.password - bcrypt.hash(req.body.password, 12, (err, hash) -> - db.hget(req.body.login, 'password', (err, password) -> - if password - bcrypt.compare(req.body.password, password, (err, match) -> - if match - req.body.password = password - db.hmset(req.body.login, req.body, -> - res.redirect(req.body.login) - ) - else - res.redirect(req.body.login) - ) - else - req.body.password = hash - db.hmset(req.body.login, req.body, -> - res.redirect(req.body.login) - ) - ) - ) - else params = [] for k,v of req.body params.push(encodeURIComponent(k), '=', encodeURIComponent(v), '&') @@ -165,7 +164,7 @@ app.post('/users', (req, res) -> res.redirect('calculator?' + params.join('')) ) -app.post('/:user/transactions', (req, res) -> +app.post('/:user/transactions', ensureAuthenticated, (req, res) -> user = req.params.user db.incr('transactions', (err, id) -> db.hmset("#{user}:transactions:#{id}", req.body, -> @@ -178,21 +177,23 @@ app.post('/:user/transactions', (req, res) -> ) app.get('/calculator', (req, res) -> + console.log(req.user) res.render('calculator', js: (-> global.js), css: (-> global.css), ) ) -app.get('/:user/edit', (req, res) -> - res.render('index', +app.get('/:user/edit', ensureAuthenticated, (req, res) -> + res.render('user', user: req.params.user, js: (-> global.js), css: (-> global.css) ) ) -app.get('/:user', (req, res) -> +app.get('/:user', ensureAuthenticated, (req, res) -> + console.log(req.user) res.render('calculator', user: req.params.user, js: (-> global.js), diff --git a/public/img/adam.jpg b/public/img/adam.jpg Binary files differnew file mode 100644 index 00000000..de83b261 --- /dev/null +++ b/public/img/adam.jpg diff --git a/public/img/jackson.jpg b/public/img/jackson.jpg Binary files differnew file mode 100644 index 00000000..08afc7e8 --- /dev/null +++ b/public/img/jackson.jpg diff --git a/public/img/yuri.jpg b/public/img/yuri.jpg Binary files differnew file mode 100644 index 00000000..48a8d7d2 --- /dev/null +++ b/public/img/yuri.jpg diff --git a/views/about.html b/views/about.html index b021f8f2..6711c039 100644 --- a/views/about.html +++ b/views/about.html @@ -24,7 +24,7 @@ </p> <p> - The software has been designed so that over time, fewer and fewer + Over time, fewer and fewer bitcoins will be created until there are a total of 21 million of them in circulation by the year 2040. Each bitcoin is divisible up to 8 decimal places, making @@ -128,15 +128,15 @@ their best interest to avoid the transaction fees charged by the credit card companies. Transaction fees end up getting built into the prices we pay for - goods and services across the board so we're all - indirectly subsidizing the big banks and credit card companies. + goods and services across the board so we're all + paying for them indirectly. </p> </div> <div class="span6"> <h1>Where can I learn more?</h1> <p> - Come to our <a href="http://meetup.com/bitcoinvan/">monthly meetup group</a> or <a href="/exchangers">contact one of us</a> directly. + Come to our <a href="http://meetup.com/bitcoinvan/">monthly meetup group</a> or <a href="/exchangers">contact one of us</a>. </p> </div> </div> diff --git a/views/exchangers.html b/views/exchangers.html index 35d01b2d..b3d86fa4 100644 --- a/views/exchangers.html +++ b/views/exchangers.html @@ -22,17 +22,42 @@ </div> <div class="row-fluid"> - <div class="span6"> - <h2>Adam Soltys</h2> - <img src="http://photos3.meetupstatic.com/photos/member/c/5/0/member_60963152.jpeg" /> + <div class="span4"> + <h2>Adam</h2> + <img src="img/adam.jpg" /> <table> <tr> <td class="first"><b>Neighbourhood:</b></td> <td>Hastings/Sunrise</td> </tr> <tr> - <td class="first"><b>Email:</b></td> - <td><a href="mailto:[email protected]">[email protected]</a></td> + <td colspan="2"><a href="https://localbitcoins.com/accounts/profile/asoltys/" class="btn">Contact</a></td> + </tr> + </table> + </div> + <div class="span4"> + <h2>Jackson</h2> + <img src="img/jackson.jpg" /> + <table> + <tr> + <td class="first"><b>Neighbourhood:</b></td> + <td>Fairview</td> + </tr> + <tr> + <td colspan="2"><a href="https://localbitcoins.com/accounts/profile/stretchwynand/" class="btn">Contact</a></td> + </tr> + </table> + </div> + <div class="span4"> + <h2>Yuri</h2> + <img src="img/yuri.jpg" /> + <table> + <tr> + <td class="first"><b>Neighbourhood:</b></td> + <td>West End</td> + </tr> + <tr> + <td colspan="2"><a href="https://localbitcoins.com/accounts/profile/beeteecee/" class="btn">Contact</a></td> </tr> </table> </div> diff --git a/views/layout.html b/views/layout.html index 072656d0..0e84c667 100644 --- a/views/layout.html +++ b/views/layout.html @@ -33,6 +33,6 @@ {{>content}} </div> <hr> - <footer>Website by Adam Soltys</footer> + <footer> </footer> </body> </html> diff --git a/views/user.html b/views/user.html new file mode 100644 index 00000000..72fbd944 --- /dev/null +++ b/views/user.html @@ -0,0 +1,43 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=480, height=752, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" /> + <title>Bitcoin Payment Calculator</title> + <link href="img/favicon.ico" rel="shortcut icon" /> + {{#css}}calculator{{/css}} + {{#js}}setup{{/js}} + </head> + <body> + <div class="container-fluid"> + <form action="users" method="post"> + <h1>Calculator Setup</h1> + + <label for="login">Username:</label> + <input type="text" id="login" name="login" value="{{user}}" /> + + <label for="password">Password:</label> + <input type="password" id="password" name="password" value="" /> + + <label for="name">Title:</label> + <input type="text" id="name" name="name" /> + + <label for="logo">Image:</label> + <input type="text" id="logo" name="logo" /> + + <label for="address">Bitcoin Address:</label> + <input type="text" id="address" name="address" /> + + <label for="symbol">Market Symbol:</label> + <select id="symbol" name="symbol"> + </select> + + <label for="commission">Commission (%):</label> + <input type="text" id="commission" name="commission" /> + + <br /> + <input class="btn" type="submit" value="Go" /> + </form> + </div> + </body> +</html> |
