feat: Manage tokens in dashboard (#5444)

This commit is contained in:
Garrett Delfosse
2023-01-13 12:20:03 -05:00
committed by GitHub
parent f76ef98a32
commit 0cf713869b
9 changed files with 457 additions and 6 deletions

View File

@ -189,10 +189,6 @@ func (api *API) tokens(rw http.ResponseWriter, r *http.Request) {
}
keys, err := api.Database.GetAPIKeysByLoginType(ctx, database.LoginTypeToken)
if errors.Is(err, sql.ErrNoRows) {
httpapi.Write(ctx, rw, http.StatusOK, []codersdk.APIKey{})
return
}
if err != nil {
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Internal error fetching API keys.",
@ -201,7 +197,7 @@ func (api *API) tokens(rw http.ResponseWriter, r *http.Request) {
return
}
var apiKeys []codersdk.APIKey
apiKeys := []codersdk.APIKey{}
for _, key := range keys {
apiKeys = append(apiKeys, convertAPIKey(key))
}