DeleteAPIKey rotates the API Key for a user @Summary Rotate the user's API Key @Description Rotate the user's API key in case the current API Key is compromised @Security ApiKeyAuth @Tags Users @Accept json @Produce json @Param userID path string true "ID of th
(c fiber.Ctx)
| 254 | // @Failure 500 {object} responses.InternalServerError |
| 255 | // @Router /users/{userID}/api-keys [delete] |
| 256 | func (h *UserHandler) DeleteAPIKey(c fiber.Ctx) error { |
| 257 | ctx, span := h.tracer.StartFromFiberCtx(c) |
| 258 | defer span.End() |
| 259 | |
| 260 | ctxLogger := h.tracer.CtxLogger(h.logger, span) |
| 261 | |
| 262 | if c.Params("userID") != string(h.userIDFomContext(c)) { |
| 263 | return h.responseUnauthorized(c) |
| 264 | } |
| 265 | |
| 266 | user, err := h.service.RotateAPIKey(ctx, c.OriginalURL(), h.userIDFomContext(c)) |
| 267 | if err != nil { |
| 268 | msg := fmt.Sprintf("cannot rotate the api key for [%T] with ID [%s]", user, h.userIDFomContext(c)) |
| 269 | ctxLogger.Error(h.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))) |
| 270 | return h.responseInternalServerError(c) |
| 271 | } |
| 272 | |
| 273 | return h.responseOK(c, "API Key rotated successfully", user) |
| 274 | } |
| 275 | |
| 276 | // subscriptionPayments returns the last 10 payments of the currently authenticated user |
| 277 | // @Summary Get the last 10 subscription payments. |
nothing calls this directly
no test coverage detected