Index function
(ctx *fiber.Ctx)
| 107 | |
| 108 | // Index function |
| 109 | func (userEndpoint *UserEndpoint) Index(ctx *fiber.Ctx) error { |
| 110 | me, _ := userEndpoint.CurrentUser(ctx) |
| 111 | if can := userEndpoint.Can(ctx, models.AdminRole); !can { |
| 112 | return ctx.Status(401).JSON(fiber.Map{ |
| 113 | "message": "You are not authorized to perform this action", |
| 114 | }) |
| 115 | } |
| 116 | params := bson.M{} |
| 117 | ctx.BodyParser(¶ms) |
| 118 | params["accountId"] = me.AccountID |
| 119 | users, err := userService.FindBy(params) |
| 120 | if err != nil { |
| 121 | return ctx.Status(401).JSON(fiber.Map{ |
| 122 | "message": err.Error(), |
| 123 | }) |
| 124 | } |
| 125 | showUsers, _ := models.ShowUserSerializer().TransformArray(users) |
| 126 | return ctx.JSON(showUsers) |
| 127 | } |
| 128 | |
| 129 | // Create function |
| 130 | func (userEndpoint *UserEndpoint) Create(ctx *fiber.Ctx) error { |
nothing calls this directly
no test coverage detected