Browse Source

fix prev commits errors

master
nicolas-arnaud 2 years ago
parent
commit
639afac56e
  1. 4
      back/volume/src/users/users.controller.ts
  2. 6
      back/volume/src/users/users.service.ts

4
back/volume/src/users/users.controller.ts

@ -212,9 +212,9 @@ export class UsersController {
async updateUser ( async updateUser (
@Body() payload: UserDto, @Body() payload: UserDto,
@Profile42() profile: Profile @Profile42() profile: Profile
): Promise<BadRequestException | User | null> { ): Promise<void> {
const user = await this.usersService.findUser(profile.id) const user = await this.usersService.findUser(profile.id)
if (user == null) throw new BadRequestException('User not found.') if (user == null) throw new BadRequestException('User not found.')
return await this.usersService.update(user, payload) await this.usersService.update(user, payload)
} }
} }

6
back/volume/src/users/users.service.ts

@ -20,7 +20,7 @@ export class UsersService {
} }
async update (user: User, changes: UserDto): Promise<void> { async update (user: User, changes: UserDto): Promise<void> {
this.usersRepository.update({id: user.id}, changes) await this.usersRepository.update({ id: user.id }, changes)
} }
async findUsers (): Promise<User[]> { async findUsers (): Promise<User[]> {
@ -57,10 +57,10 @@ export class UsersService {
async findUser (ftId: number): Promise<User> { async findUser (ftId: number): Promise<User> {
const user = await this.usersRepository.findOneBy({ ftId }) const user = await this.usersRepository.findOneBy({ ftId })
if (user == null) throw new BadRequestException("User not exist") if (user == null) throw new BadRequestException('User not exist')
user.lastAccess = Date.now() user.lastAccess = Date.now()
if (user.status === 'offline') user.status = 'online' if (user.status === 'offline') user.status = 'online'
await this.update.(user) await this.update(user, user)
return user return user
} }

Loading…
Cancel
Save