ByID function
(ctx *fiber.Ctx)
| 89 | |
| 90 | // ByID function |
| 91 | func (userEndpoint *UserEndpoint) ByID(ctx *fiber.Ctx) error { |
| 92 | me, _ := userEndpoint.CurrentUser(ctx) |
| 93 | if can := userEndpoint.Can(ctx, models.AdminRole); !can { |
| 94 | return ctx.Status(401).JSON(fiber.Map{ |
| 95 | "message": "You are not authorized to perform this action", |
| 96 | }) |
| 97 | } |
| 98 | user, err := userService.ByID(ctx.Params("id"), me.AccountID) |
| 99 | if err != nil { |
| 100 | return ctx.Status(404).JSON(fiber.Map{ |
| 101 | "message": err.Error(), |
| 102 | }) |
| 103 | } |
| 104 | showUser := models.ShowUserSerializer().Transform(user) |
| 105 | return ctx.JSON(showUser) |
| 106 | } |
| 107 | |
| 108 | // Index function |
| 109 | func (userEndpoint *UserEndpoint) Index(ctx *fiber.Ctx) error { |
no test coverage detected