MCPcopy Create free account
hub / github.com/devinterface/startersaas-go-api / Index

Method Index

endpoints/user.endpoint.go:109–127  ·  view source on GitHub ↗

Index function

(ctx *fiber.Ctx)

Source from the content-addressed store, hash-verified

107
108// Index function
109func (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(&params)
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
130func (userEndpoint *UserEndpoint) Create(ctx *fiber.Ctx) error {

Callers

nothing calls this directly

Calls 4

ShowUserSerializerFunction · 0.92
CurrentUserMethod · 0.80
CanMethod · 0.80
FindByMethod · 0.45

Tested by

no test coverage detected