diff options
| author | Pitu <[email protected]> | 2019-03-29 00:44:33 +0900 |
|---|---|---|
| committer | Pitu <[email protected]> | 2019-03-29 00:44:33 +0900 |
| commit | 0f4d196c8c67e1cdf4296ed678a6155cf369406d (patch) | |
| tree | 44ca44d6615335c5cda7934f1d968775e6bb087b | |
| parent | WIP apiKey validation (diff) | |
| parent | Merge pull request #190 from robflop/patch-2 (diff) | |
| download | host.fuwn.me-0f4d196c8c67e1cdf4296ed678a6155cf369406d.tar.xz host.fuwn.me-0f4d196c8c67e1cdf4296ed678a6155cf369406d.zip | |
Fix conflicts
| -rw-r--r-- | package.json | 3 | ||||
| -rw-r--r-- | src/api/database/seeds/initial.js | 2 | ||||
| -rw-r--r-- | src/api/routes/auth/registerPOST.js | 3 | ||||
| -rw-r--r-- | src/api/structures/Route.js | 2 | ||||
| -rw-r--r-- | src/site/pages/dashboard/account.vue | 3 | ||||
| -rw-r--r-- | src/site/pages/login.vue | 2 | ||||
| -rw-r--r-- | src/site/store/index.js | 1 |
7 files changed, 8 insertions, 8 deletions
diff --git a/package.json b/package.json index 4146a70..8b43196 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "seed": "yarn knex seed:run", "api": "node src/api/structures/Server", "site": "cross-env NODE_ENV=production nuxt start", - "update": "git pull && yarn install && yarn migrate && yarn build" + "update": "git pull && yarn install && yarn migrate && yarn build && yarn restart", + "restart": "pm2 restart lolisafe-api && pm2 restart lolisafe-website" }, "repository": { "type": "git", diff --git a/src/api/database/seeds/initial.js b/src/api/database/seeds/initial.js index 0ea7bb4..bb8b915 100644 --- a/src/api/database/seeds/initial.js +++ b/src/api/database/seeds/initial.js @@ -11,9 +11,7 @@ exports.seed = async db => { await db.table('users').insert({ username: process.env.ADMIN_ACCOUNT, password: hash, - apiKey: randomstring.generate(64), passwordEditedAt: now, - apiKeyEditedAt: now, createdAt: now, editedAt: now, enabled: true, diff --git a/src/api/routes/auth/registerPOST.js b/src/api/routes/auth/registerPOST.js index 0bd8cfd..feeb360 100644 --- a/src/api/routes/auth/registerPOST.js +++ b/src/api/routes/auth/registerPOST.js @@ -1,7 +1,6 @@ const Route = require('../../structures/Route'); const log = require('../../utils/Log'); const bcrypt = require('bcrypt'); -const randomstring = require('randomstring'); const moment = require('moment'); class registerPOST extends Route { @@ -48,8 +47,6 @@ class registerPOST extends Route { username, password: hash, passwordEditedAt: now, - apiKey: randomstring.generate(64), - apiKeyEditedAt: now, createdAt: now, editedAt: now, enabled: true, diff --git a/src/api/structures/Route.js b/src/api/structures/Route.js index ecb2be0..8a73454 100644 --- a/src/api/structures/Route.js +++ b/src/api/structures/Route.js @@ -28,8 +28,8 @@ class Route { authorize(req, res) { if (this.options.bypassAuth) return this.run(req, res, db); if (req.headers.apiKey) return this.authorizeApiKey(req, res, req.headers.apiKey); - if (!req.headers.authorization) return res.status(401).json({ message: 'No authorization header provided' }); + const token = req.headers.authorization.split(' ')[1]; if (!token) return res.status(401).json({ message: 'No authorization header provided' }); diff --git a/src/site/pages/dashboard/account.vue b/src/site/pages/dashboard/account.vue index df07591..3ccbc31 100644 --- a/src/site/pages/dashboard/account.vue +++ b/src/site/pages/dashboard/account.vue @@ -132,7 +132,8 @@ export default { }, promptNewAPIKey() { this.$dialog.confirm({ - message: 'Are you sure you want to regenerate your API key?', + type: 'is-danger', + message: 'Are you sure you want to regenerate your API key? Previously generated API keys will stop working. Make sure to write the new key down as this is the only time it will be displayed to you.', onConfirm: () => this.requestNewAPIKey() }); }, diff --git a/src/site/pages/login.vue b/src/site/pages/login.vue index c713674..6e0be3e 100644 --- a/src/site/pages/login.vue +++ b/src/site/pages/login.vue @@ -109,7 +109,9 @@ export default { password: this.password }); this.$axios.setToken(data.token, 'Bearer'); + document.cookie = `token=${encodeURIComponent(data.token)}`; this.$store.dispatch('login', { token: data.token, user: data.user }); + this.redirect(); } catch (error) { this.$onPromiseError(error); diff --git a/src/site/store/index.js b/src/site/store/index.js index 13e49c3..a4a0d51 100644 --- a/src/site/store/index.js +++ b/src/site/store/index.js @@ -54,6 +54,7 @@ export const actions = { if (req.headers.cookie) { try { token = cookieparser.parse(req.headers.cookie).token; + console.log(token); commit('loggedIn', true); commit('token', token); |