MCPcopy Create free account
hub / github.com/SwishHQ/spread / CreateAuthKey

Method CreateAuthKey

src/controller/auth_key.controller.go:24–37  ·  view source on GitHub ↗
(ctx *fiber.Ctx)

Source from the content-addressed store, hash-verified

22}
23
24func (c *authKeyController) CreateAuthKey(ctx *fiber.Ctx) error {
25 authKey := types.CreateAuthKeyRequest{}
26 validationErrors := utils.BindAndValidate(ctx, &authKey)
27 if len(validationErrors) > 0 {
28 return utils.ValidationErrorResponse(ctx, validationErrors)
29 }
30 user := ctx.Locals("user").(*model.User)
31 createdBy := user.Username
32 createdAuthKey, err := c.authKeyService.CreateAuthKey(authKey.Name, createdBy)
33 if err != nil {
34 return utils.ErrorResponse(ctx, err.Error())
35 }
36 return utils.SuccessResponse(ctx, createdAuthKey)
37}
38
39func (c *authKeyController) GetAllAuthKeys(ctx *fiber.Ctx) error {
40 authKeys, err := c.authKeyService.GetAllAuthKeys(ctx.Context())

Callers

nothing calls this directly

Calls 5

BindAndValidateFunction · 0.92
ValidationErrorResponseFunction · 0.92
ErrorResponseFunction · 0.92
SuccessResponseFunction · 0.92
CreateAuthKeyMethod · 0.65

Tested by

no test coverage detected