OOP is my passion ( ͡° ͜ʖ ͡°)

This commit is contained in:
2025-01-04 18:35:53 +01:00
parent 0b4420f956
commit 067976c54a
46 changed files with 165 additions and 164 deletions

View File

@ -6,14 +6,15 @@ export default class LoginEvent extends BaseEvent {
this.socket.on('login', this.handleEvent.bind(this))
}
private handleEvent(): void {
private async handleEvent() {
try {
if (!this.socket.userId) {
this.logger.warn('Login attempt without user data')
return
}
this.socket.emit('logged_in', { user: UserRepository.getById(this.socket.userId) })
const userRepository = new UserRepository()
this.socket.emit('logged_in', { user: userRepository.getById(this.socket.userId) })
this.logger.info(`User logged in: ${this.socket.userId}`)
} catch (error: any) {
this.logger.error('login error: ' + error.message)