diff options
| author | Elizabeth <elizabeth@simponic.xyz> | 2024-04-09 18:39:14 -0400 |
|---|---|---|
| committer | simponic <simponic@hatecomputers.club> | 2024-04-09 18:39:14 -0400 |
| commit | 1d75bf7489527925217bd5611ba7910c0ffe077c (patch) | |
| tree | 3b6e6056912648a88e1e42c1e42ed7e58e2d4701 /api/keys/keys.go | |
| parent | ee49015cc90e6c136ad94243fffc9241b9506a36 (diff) | |
| download | hatecomputers.club-1d75bf7489527925217bd5611ba7910c0ffe077c.tar.gz hatecomputers.club-1d75bf7489527925217bd5611ba7910c0ffe077c.zip | |
profiles (#7)
Reviewed-on: https://git.hatecomputers.club/hatecomputers/hatecomputers.club/pulls/7
Co-authored-by: Elizabeth <elizabeth@simponic.xyz>
Co-committed-by: Elizabeth <elizabeth@simponic.xyz>
Diffstat (limited to 'api/keys/keys.go')
| -rw-r--r-- | api/keys/keys.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/api/keys/keys.go b/api/keys/keys.go index cef3f3c..7702f3d 100644 --- a/api/keys/keys.go +++ b/api/keys/keys.go @@ -27,8 +27,8 @@ func ListAPIKeysContinuation(context *types.RequestContext, req *http.Request, r func CreateAPIKeyContinuation(context *types.RequestContext, req *http.Request, resp http.ResponseWriter) types.ContinuationChain { return func(success types.Continuation, failure types.Continuation) types.ContinuationChain { - formErrors := types.FormError{ - Errors: []string{}, + formErrors := types.BannerMessages{ + Messages: []string{}, } numKeys, err := database.CountUserAPIKeys(context.DBConn, context.User.ID) @@ -39,11 +39,11 @@ func CreateAPIKeyContinuation(context *types.RequestContext, req *http.Request, } if numKeys >= MAX_USER_API_KEYS { - formErrors.Errors = append(formErrors.Errors, "max types keys reached") + formErrors.Messages = append(formErrors.Messages, "max types keys reached") } - if len(formErrors.Errors) > 0 { - (*context.TemplateData)["FormError"] = formErrors + if len(formErrors.Messages) > 0 { + (*context.TemplateData)["Error"] = formErrors return failure(context, req, resp) } @@ -56,6 +56,11 @@ func CreateAPIKeyContinuation(context *types.RequestContext, req *http.Request, resp.WriteHeader(http.StatusInternalServerError) return failure(context, req, resp) } + + formSuccess := types.BannerMessages{ + Messages: []string{"key created."}, + } + (*context.TemplateData)["Success"] = formSuccess return success(context, req, resp) } } @@ -82,6 +87,11 @@ func DeleteAPIKeyContinuation(context *types.RequestContext, req *http.Request, return failure(context, req, resp) } + formSuccess := types.BannerMessages{ + Messages: []string{"key deleted."}, + } + (*context.TemplateData)["Success"] = formSuccess + return success(context, req, resp) } } |
