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

Method AddUser

endpoints/team.endpoint.go:143–158  ·  view source on GitHub ↗

Add user function

(ctx *fiber.Ctx)

Source from the content-addressed store, hash-verified

141
142// Add user function
143func (teamEndpoint *TeamEndpoint) AddUser(ctx *fiber.Ctx) error {
144 me, _ := userEndpoint.CurrentUser(ctx)
145 if can := userEndpoint.Can(ctx, models.AdminRole); !can {
146 return ctx.Status(401).JSON(fiber.Map{
147 "message": "You are not authorized to perform this action",
148 })
149 }
150 team, err := teamService.AddUser(ctx.Params("id"), me.AccountID, ctx.Params("userId"))
151 if err != nil {
152 return ctx.Status(422).JSON(fiber.Map{
153 "message": err.Error(),
154 })
155 }
156 showTeam := models.ShowTeamSerializer().Transform(team)
157 return ctx.JSON(showTeam)
158}
159
160// REmove user function
161func (teamEndpoint *TeamEndpoint) RemoveUser(ctx *fiber.Ctx) error {

Callers

nothing calls this directly

Calls 3

ShowTeamSerializerFunction · 0.92
CurrentUserMethod · 0.80
CanMethod · 0.80

Tested by

no test coverage detected