Add user function
(ctx *fiber.Ctx)
| 141 | |
| 142 | // Add user function |
| 143 | func (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 |
| 161 | func (teamEndpoint *TeamEndpoint) RemoveUser(ctx *fiber.Ctx) error { |
nothing calls this directly
no test coverage detected