Added online column to user and char. models, updated send chat message event to new format, removed unused code, fixed typo, replaced console.log()'s with logger

This commit is contained in:
2024-09-08 03:14:55 +02:00
parent 7682d1fd01
commit a64506d3ee
5 changed files with 56 additions and 43 deletions

View File

@ -3,6 +3,7 @@ import { TSocket } from '../utilities/types'
import config from '../utilities/config'
import UserRepository from '../repositories/userRepository'
import { User } from '@prisma/client'
import logger from '../utilities/logger'
/**
* Socket io jwt auth middleware
@ -11,7 +12,7 @@ import { User } from '@prisma/client'
*/
export async function Authentication(socket: TSocket, next: any) {
if (!socket.request.headers.cookie) {
console.log('No cookie provided')
logger.warn('No cookie provided')
return next(new Error('Authentication error'))
}
@ -32,7 +33,7 @@ export async function Authentication(socket: TSocket, next: any) {
if (token) {
verify(token, config.JWT_SECRET, async (err: any, decoded: any) => {
if (err) {
console.log('err')
logger.error('Invalid token')
return next(new Error('Authentication error'))
}
@ -40,7 +41,7 @@ export async function Authentication(socket: TSocket, next: any) {
next()
})
} else {
console.log('No token provided')
logger.warn('No token provided')
next(new Error('Authentication error'))
}
}