import { logger } from '../helpers/logger'
import { Socket } from 'socket.io'
import { getAccessToken } from '../lib/oauth-model'
-import { handleIdAndPassLogin, oAuthServer } from '@server/lib/auth'
+import { oAuthServer } from '@server/lib/auth'
function authenticate (req: express.Request, res: express.Response, next: express.NextFunction, authenticateInQuery = false) {
const options = authenticateInQuery ? { allowBearerTokensInQueryString: true } : {}
function authenticatePromiseIfNeeded (req: express.Request, res: express.Response, authenticateInQuery = false) {
return new Promise(resolve => {
// Already authenticated? (or tried to)
- if (res.locals.oauth && res.locals.oauth.token.User) return resolve()
+ if (res.locals.oauth?.token.User) return resolve()
if (res.locals.authenticated === false) return res.sendStatus(401)