diff options
| author | Elizabeth Hunt <elizabeth@simponic.xyz> | 2024-04-06 13:36:13 -0600 |
|---|---|---|
| committer | Elizabeth Hunt <elizabeth@simponic.xyz> | 2024-04-06 13:36:13 -0600 |
| commit | 5177735b835289c8437799536d3654e5ab142fa3 (patch) | |
| tree | aa5a0c9588ca7b1b97ccd6c4f0cf245d2c3ac162 /api/keys | |
| parent | ae640a253edb5935380975fb07430e910a83b340 (diff) | |
| download | hatecomputers.club-5177735b835289c8437799536d3654e5ab142fa3.tar.gz hatecomputers.club-5177735b835289c8437799536d3654e5ab142fa3.zip | |
finish auth tests
Diffstat (limited to 'api/keys')
| -rw-r--r-- | api/keys/keys.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/api/keys/keys.go b/api/keys/keys.go index ad380fc..cef3f3c 100644 --- a/api/keys/keys.go +++ b/api/keys/keys.go @@ -62,27 +62,26 @@ func CreateAPIKeyContinuation(context *types.RequestContext, req *http.Request, func DeleteAPIKeyContinuation(context *types.RequestContext, req *http.Request, resp http.ResponseWriter) types.ContinuationChain { return func(success types.Continuation, failure types.Continuation) types.ContinuationChain { - key := req.FormValue("key") + apiKey := req.FormValue("key") - typesKey, err := database.GetAPIKey(context.DBConn, key) + key, err := database.GetAPIKey(context.DBConn, apiKey) if err != nil { log.Println(err) resp.WriteHeader(http.StatusInternalServerError) return failure(context, req, resp) } - if (typesKey == nil) || (typesKey.UserID != context.User.ID) { + if (key == nil) || (key.UserID != context.User.ID) { resp.WriteHeader(http.StatusUnauthorized) return failure(context, req, resp) } - err = database.DeleteAPIKey(context.DBConn, key) + err = database.DeleteAPIKey(context.DBConn, apiKey) if err != nil { log.Println(err) resp.WriteHeader(http.StatusInternalServerError) return failure(context, req, resp) } - http.Redirect(resp, req, "/keys", http.StatusFound) return success(context, req, resp) } } |
