Compare commits

...

2 Commits
0.4.2 ... 0.4.3

Author SHA1 Message Date
Nicolai Ort 0afa80345d 🚀RELEASE 0.4.3
continuous-integration/drone/push Build is passing Details
2021-08-21 07:35:41 +02:00
Nicolai Ort dbb0d177b8
Fixed auth error crashing the entire server thanks to fastify handling stuff not the same way that they do in the docs.....
closes #1
2021-08-21 07:35:13 +02:00
3 changed files with 28 additions and 15 deletions

View File

@ -2,9 +2,16 @@
All notable changes to this project will be documented in this file. Dates are displayed in UTC. All notable changes to this project will be documented in this file. Dates are displayed in UTC.
#### [0.4.3](https://git.odit.services/kauft.es/linkylinky/compare/0.4.2...0.4.3)
- Fixed auth error crashing the entire server thanks to fastify handling stuff not the same way that they do in the docs..... [`#1`](https://git.odit.services/kauft.es/linkylinky/issues/1)
#### [0.4.2](https://git.odit.services/kauft.es/linkylinky/compare/0.4.1...0.4.2) #### [0.4.2](https://git.odit.services/kauft.es/linkylinky/compare/0.4.1...0.4.2)
> 18 August 2021
- Changed register api route and added user deletion route [`588f3ba`](https://git.odit.services/kauft.es/linkylinky/commit/588f3bae8980f76461d20e15475ec797078b0b54) - Changed register api route and added user deletion route [`588f3ba`](https://git.odit.services/kauft.es/linkylinky/commit/588f3bae8980f76461d20e15475ec797078b0b54)
- 🚀RELEASE 0.4.2 [`4ffc06d`](https://git.odit.services/kauft.es/linkylinky/commit/4ffc06db7bb84bc7bfc9c57a80927f7201185274)
#### [0.4.1](https://git.odit.services/kauft.es/linkylinky/compare/0.4.0...0.4.1) #### [0.4.1](https://git.odit.services/kauft.es/linkylinky/compare/0.4.0...0.4.1)

View File

@ -1,6 +1,6 @@
{ {
"name": "@odit/shortener-backend", "name": "@odit/shortener-backend",
"version": "0.4.2", "version": "0.4.3",
"main": "index.js", "main": "index.js",
"license": "MIT", "license": "MIT",
"private": false, "private": false,

View File

@ -45,25 +45,31 @@ fastify.decorate('verifyJWT', function async(request, reply, done) {
fastify.jwt.verify(token, async (err, decoded) => { fastify.jwt.verify(token, async (err, decoded) => {
if (err) { if (err) {
fastify.log.error(err) fastify.log.error("JWT validation failed:")
done(new Error("JWT Validation failed")) done(new Error("JWT Validation failed"));
} }
fastify.log.info(`Token verified. User is ${decoded.payload.user}`); else {
request.user = decoded.payload.user; if (!decoded.payload) {
done(new Error("JWT is empty"));
}
fastify.log.info(`Token verified. User is ${decoded.payload.user}`);
const jwtcount = (await knex.select('jwtcount') const jwtcount = (await knex.select('jwtcount')
.from('users') .from('users')
.where('username', '=', decoded.payload.user) .where('username', '=', decoded.payload.user)
.limit(1))[0].jwtcount; .limit(1))[0].jwtcount;
if (decoded.payload.jwtcount < jwtcount) { if (decoded.payload.jwtcount < jwtcount) {
fastify.log.error("Auth ended at jwtcount") fastify.log.error("Auth ended at jwtcount")
done(new Error("JWT in no longer valid")) done(new Error("JWT in no longer valid"))
}
else {
fastify.log.info(`JWT count verified`);
request.user = decoded.payload.user;
done()
}
} }
fastify.log.info(`JWT count verified`);
done()
}) })
}) })
//Automagic Amazn redirects on /a/ //Automagic Amazn redirects on /a/