Me function
(ctx *fiber.Ctx)
| 13 | |
| 14 | // Me function |
| 15 | func (userEndpoint *UserEndpoint) Me(ctx *fiber.Ctx) error { |
| 16 | me, err := userEndpoint.CurrentUser(ctx) |
| 17 | if err != nil { |
| 18 | return ctx.Status(401).JSON(fiber.Map{ |
| 19 | "message": err.Error(), |
| 20 | }) |
| 21 | } |
| 22 | showUser := models.ShowUserSerializer().Transform(me) |
| 23 | |
| 24 | queryAccount := ctx.Query("withAccount") |
| 25 | if queryAccount == "true" { |
| 26 | account, err := accountService.ByID(me.AccountID) |
| 27 | if err != nil { |
| 28 | return ctx.Status(404).JSON(fiber.Map{ |
| 29 | "message": err.Error(), |
| 30 | }) |
| 31 | } |
| 32 | showAccount := models.ShowAccountSerializer().Transform(account) |
| 33 | showUser["account"] = showAccount |
| 34 | } |
| 35 | |
| 36 | return ctx.JSON(showUser) |
| 37 | } |
| 38 | |
| 39 | // UpdateMe function |
| 40 | func (userEndpoint *UserEndpoint) UpdateMe(ctx *fiber.Ctx) error { |
nothing calls this directly
no test coverage detected