OOP is my passion ( ͡° ͜ʖ ͡°)
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user