forked from noxious/server
#174: Refactor character manager into zoneManager for better DX, major refactor of time and weather system (data is stored in DB now instead of JSON file), npm update, npm format, many other improvements
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { Server } from 'socket.io'
|
||||
import { TSocket } from '../utilities/types'
|
||||
import { gameLogger } from '../utilities/logger'
|
||||
import UserRepository from '../repositories/userRepository'
|
||||
|
||||
export default class LoginEvent {
|
||||
constructor(
|
||||
@ -14,13 +15,13 @@ export default class LoginEvent {
|
||||
|
||||
private handleLogin(): void {
|
||||
try {
|
||||
if (!this.socket.user) {
|
||||
if (!this.socket.userId) {
|
||||
gameLogger.warn('Login attempt without user data')
|
||||
return
|
||||
}
|
||||
|
||||
this.socket.emit('logged_in', { user: this.socket.user })
|
||||
gameLogger.info(`User logged in: ${this.socket.user.id}`)
|
||||
this.socket.emit('logged_in', { user: UserRepository.getById(this.socket.userId) })
|
||||
gameLogger.info(`User logged in: ${this.socket.userId}`)
|
||||
} catch (error: any) {
|
||||
gameLogger.error('login error', error.message)
|
||||
}
|
||||
|
Reference in New Issue
Block a user