feat: auto userdata fetch

fix: gql directives and overall minor fixes
This commit is contained in:
Sérgio Salgado 2021-04-07 16:11:06 +01:00 committed by Josh Harvey
parent 3f6c0e6037
commit 9fa97725ec
22 changed files with 94 additions and 127 deletions

View file

@ -1,5 +1,6 @@
const otplib = require('otplib')
const bcrypt = require('bcrypt')
const { AuthenticationError } = require('apollo-server-express')
const loginHelper = require('../../services/login')
const T = require('../../../time')
@ -27,7 +28,7 @@ function authenticateUser(username, password) {
const getUserData = context => {
const lidCookie = context.req.cookies && context.req.cookies.lid
if (!lidCookie) throw new authErrors.InvalidCredentialsError()
if (!lidCookie) throw new AuthenticationError()
const user = context.req.session.user
return user