Skip to content

Instantly share code, notes, and snippets.

@QuadradS
Created February 17, 2020 11:17
Show Gist options
  • Save QuadradS/d6be891537a947e7b0a4815d96cd587e to your computer and use it in GitHub Desktop.
Save QuadradS/d6be891537a947e7b0a4815d96cd587e to your computer and use it in GitHub Desktop.
Controllers
import { Autowired, BaseController, GetMapping, PatchMapping, RequestBody, RestController, User } from 'ts-framework'
import Injectables from '../enums/injectables'
import Paths from '../enums/paths'
import { AuthJwtPayloadDTO, ChangePasswordByRecoveryTokenDTO, UserResponseDTO } from 'goin-shared'
import { UserService } from '../services'
@RestController
class UserController extends BaseController {
private userService: UserService
@Autowired(Injectables.services.user)
setUserService(userService: UserService) {
this.userService = userService
}
@GetMapping(Paths.user.mobileGetCurrentUser)
protected loginByCredentials(@User() authJwtPayload: AuthJwtPayloadDTO): Promise<UserResponseDTO> {
return this.userService.getCurrentUser(authJwtPayload)
}
@PatchMapping(Paths.user.changePasswordByRecoveryToken)
protected changePasswordByRecoveryToken(
@RequestBody(ChangePasswordByRecoveryTokenDTO) dto: ChangePasswordByRecoveryTokenDTO
): Promise<void> {
return this.userService.updateUserPasswordByRecoveryToken(dto)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment