aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app.js6
-rw-r--r--config/config.json.sample2
-rw-r--r--db.js2
-rw-r--r--migrations/20180128181238-create-user.js7
-rw-r--r--seeders/20180128223744-users.js4
5 files changed, 11 insertions, 10 deletions
diff --git a/app.js b/app.js
index 004bc263..54fe78a5 100644
--- a/app.js
+++ b/app.js
@@ -39,7 +39,7 @@ const l = console.log
let fetchRates
(fetchRates = () => {
- restClient.tickerGlobalPerSymbol('BTCUSD', (data) => {
+ restClient.tickerGlobalPerSymbol('BTCCAD', (data) => {
app.set('rates', JSON.parse(data))
})
setTimeout(fetchRates, 120000)
@@ -50,19 +50,17 @@ const l = console.log
})
app.post('/login', (req, res) => {
- console.log('logging in')
db.User.findOne({
where: {
username: req.body.username
}
}).then((user) => {
bcrypt.compare(req.body.password, user.password).then((result) => {
- console.log('password was good')
if (result) {
let payload = { username: user.username }
let token = jwt.sign(payload, process.env.SECRET)
res.cookie('token', token, { expires: new Date(Date.now() + 9999999) })
- res.json({ token: token })
+ res.json({ user, token })
} else {
res.status(401).end()
}
diff --git a/config/config.json.sample b/config/config.json.sample
index 0b6e4918..8599ef5b 100644
--- a/config/config.json.sample
+++ b/config/config.json.sample
@@ -23,7 +23,7 @@
"auto": {
"host": "localhost",
"dialect": "mysql",
- "tables": ["Users"],
+ "tables": ["users"],
"logging": false,
"directory": false,
"dialectOptions": {
diff --git a/db.js b/db.js
index 5354f61d..9dfe210e 100644
--- a/db.js
+++ b/db.js
@@ -22,7 +22,7 @@ const auto = new SequelizeAuto(
config.development.password,
config.auto
)
-const tables = { 'User': 'Users' }
+const tables = { 'User': 'users' }
const db = new Sequelize(
config.development.database,
diff --git a/migrations/20180128181238-create-user.js b/migrations/20180128181238-create-user.js
index 30cc4bbc..50424e18 100644
--- a/migrations/20180128181238-create-user.js
+++ b/migrations/20180128181238-create-user.js
@@ -1,7 +1,7 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
- return queryInterface.createTable('Users', {
+ return queryInterface.createTable('users', {
id: {
allowNull: false,
autoIncrement: true,
@@ -41,6 +41,9 @@ module.exports = {
privkey: {
type: Sequelize.STRING
},
+ index: {
+ type: Sequelize.INTEGER
+ },
createdAt: {
allowNull: false,
type: Sequelize.DATE
@@ -52,6 +55,6 @@ module.exports = {
});
},
down: (queryInterface, Sequelize) => {
- return queryInterface.dropTable('Users');
+ return queryInterface.dropTable('users');
}
};
diff --git a/seeders/20180128223744-users.js b/seeders/20180128223744-users.js
index 4e0830af..40e1bfef 100644
--- a/seeders/20180128223744-users.js
+++ b/seeders/20180128223744-users.js
@@ -2,7 +2,7 @@
module.exports = {
up: (queryInterface, Sequelize) => {
- return queryInterface.bulkInsert('Users', [{
+ return queryInterface.bulkInsert('users', [{
username: 'yy',
address: '178D54KpAd2mvTtuhjYNknuQ6XPU7X9R7S',
@@ -20,6 +20,6 @@ module.exports = {
},
down: (queryInterface, Sequelize) => {
- return queryInterface.bulkDelete('Users', null, {});
+ return queryInterface.bulkDelete('users', null, {});
}
};