Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
v0.9.8 hash passwords, change favicon from default, change title, cha…
Browse files Browse the repository at this point in the history
…nge class to className
  • Loading branch information
pacificpelican committed Sep 2, 2017
1 parent f980cfe commit 71b2dfc
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
17 changes: 15 additions & 2 deletions eapp.js
Expand Up @@ -6,6 +6,18 @@ var app = express();
var server = require('http').Server(app);
var io = require('socket.io')(server);

const crypto = require('crypto');

const secret = 'abcdefg';

function getHash(src) {
const hash = crypto.createHmac('sha256', src)
.update('I love cupcakes') // via https://nodejs.org/api/crypto.html
.digest('hex');
console.log(src + " hashed is " + hash);
return hash;
}

io.on('connection', function(socket){
socket.on('chat message', function(msg){
io.emit('chat message', msg);
Expand Down Expand Up @@ -59,8 +71,9 @@ passport.use(new Strategy(
db.collection('testcollection').find( { "username": { $eq: username } } ).toArray(function (err, result) {
console.log("result:")
console.log(result)
var hashedPW = result[0].userpassword;
if (result.length > 0) {
if (result[0].userpassword == password) {
if (hashedPW == getHash(password)) {
return cb(null, username);
}
else {
Expand Down Expand Up @@ -108,7 +121,7 @@ app.get('/register', (req, res) => {

app.post('/process/register', (req, res) => {
var user_name = req.body.login;
var user_pw = req.body.password;
var user_pw = getHash(req.body.password);
console.log(req.body);
let homeLink = "<a href='../../..'>Home</a>";
let createdAt = Date.now();
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "ychat",
"version": "0.9.7",
"version": "0.9.8",
"private": true,
"dependencies": {
"react": "^15.5.4",
Expand Down
Binary file modified public/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion public/index.html
Expand Up @@ -22,7 +22,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>yogachat</title>
<title>Y Chat</title>
</head>
<body>
<noscript>
Expand Down
4 changes: 2 additions & 2 deletions src/App.js
Expand Up @@ -101,14 +101,14 @@ class MyInput extends Component {
return (
<div id="innerContainer">
<div id="title_area">
<h1 class="nasty_chat">
<h1 className="nasty_chat">
Y CHAT
</h1>
<h5 id="tagline">
from <a href="http://danmckeown.info">Dan McKeown</a>
</h5>
<h6 id="usernameheader">
<span id="showusernamelabel" class="userinfo">user:</span> <span id="showusername" class="userinfo"></span>
<span id="showusernamelabel" className="userinfo">user:</span> <span id="showusername" className="userinfo"></span>
</h6>
<p>
<span id="cantclick"><a href="#" onClick={function() { alert('ok the cursor should be free')}}>just type!</a></span>
Expand Down

0 comments on commit 71b2dfc

Please sign in to comment.