Skip to content

Commit

Permalink
added password to send message
Browse files Browse the repository at this point in the history
  • Loading branch information
andineck committed Nov 21, 2013
1 parent bf3f403 commit 0d390d6
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
20 changes: 18 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,28 @@ app.get('/contact', function(req, res) {

app.post('/messages/send', function(req, res) {
console.log('/messages/send', req.body);

// check password
var crypto = require('crypto');
var hash = crypto.createHash('sha256');
hash.update(req.body.password);
hash = hash.digest('hex');
if (hash !== settings.password) {
res.send(200, {
message: 'wrong password',
status: 400
});
res.end();
return;
}

// send message
client.sendMessage(req.body, function(err, data) {
if (err) {
console.error('/messages/send error:', err, data);
res.send(200, err);
res.end();
return
return;
}
console.log('/messages/send success:', err, data);
res.send(200, {
Expand Down Expand Up @@ -172,7 +188,7 @@ app.post('/voice/receive/gather', function(req, res) {
length: '1'
}).hangup();
}

res.type('text/xml');
res.send(200, twiml.toString());

Expand Down
2 changes: 1 addition & 1 deletion public/css/bootstrap.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h1><small>Welcome to</small><br><span class="brand-name">Com Router</span><hr c
<h2 class="intro-text text-center"><strong>Use </strong> Cases</h2>
<hr>

<p>Want your applications and services to reach more people? Here's how Com Router can help you:
<p>Want your applications and services to reach more people worldwide? Here's how Com Router can help you:
</p>

<br/>
Expand All @@ -112,6 +112,7 @@ <h2 class="intro-text text-center"><strong>Use </strong> Cases</h2>
<li>make calls</li>
<li>control your app via voice</li>
<li>combox, conference, ect.</li>
<li>local numbers available in almost every country</li>
</ul>

<br/>
Expand Down
2 changes: 2 additions & 0 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ $(function() {
var from = $('#fromNumber').val();
var to = $('#toNumber').val();
var message = $('#message').val();
var password = $('#password').val();

// asynchronously post with superagent to server
superagent
Expand All @@ -33,6 +34,7 @@ $(function() {
.send({
'from': from,
'to': to,
'password': password,
'body': message
})
.end(function(err, res) {
Expand Down
10 changes: 7 additions & 3 deletions public/message.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,18 @@ <h2 class="intro-text text-center">Send <strong>Message</strong></h2>
<p>Send an SMS to anyone you want. Just type the number and your message...</p>
<form role="form">
<div class="row">
<div class="form-group col-lg-6">
<div class="form-group col-lg-4">
<label for="fromNumber">From</label>
<input id="fromNumber" type="phone" class="form-control" value="+15878000700" disabled>
</div>
<div class="form-group col-lg-6">
<div class="form-group col-lg-4">
<label for="toNumber">Number</label>
<input id="toNumber" type="phone" class="form-control" placeholder="e.g. +41790070707">
</div>
<div class="form-group col-lg-4">
<label for="password">Password</label>
<input id="password" type="password" class="form-control" placeholder="">
</div>
<div class="clearfix"></div>
<div class="form-group col-lg-12">
<label>Message</label>
Expand All @@ -75,7 +79,7 @@ <h2 class="intro-text text-center">Send <strong>Message</strong></h2>
</div>

<div id="response" class="col-lg-12" style="display:none;">
<p>Respect...</p>
<p>...</p>
</div>

</div>
Expand Down
1 change: 1 addition & 0 deletions settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"password": "3430f9b3745e624d67781c0cf4afd5a473a54a7efdfb03338b795b94b82b0f0b",
"accountSid": "AC6eef93ec9f5bfd1a97db63206bced1b2",
"authToken": "3bb077d692424820b448475af9810522"
}

0 comments on commit 0d390d6

Please sign in to comment.