Fix most glaring bugs and vulnerabilities

This commit is contained in:
Luka Romih
2023-05-08 23:25:25 +02:00
parent 9867875ef2
commit d0e53fee3b
144 changed files with 2231 additions and 2981 deletions
+4 -5
View File
@@ -21,6 +21,9 @@ passport.deserializeUser(async (id, done) => {
const user = await User.fetchDeserializedDataById(id)
// TODO Consider what to do if no user was found?
// TODO This is a current workaround until session invalidation is implemented.
if (user.status !== 'active') return done(null, false)
done(null, user)
} catch (error) {
done(error)
@@ -32,11 +35,7 @@ passport.use(
{ passReqToCallback: true, usernameField: 'usernameOrEmail' },
async (req, usernameOrEmail, password, done) => {
try {
const { rows } = await db.query(
'SELECT id, status, bcrypt_hash FROM "user" WHERE username = $1 OR email = $1',
[usernameOrEmail]
)
const user = rows[0]
const user = await User.fetchByUsernameOrEmail(usernameOrEmail)
if (!user) {
return done(null, false, {