Skip to content

Commit

Permalink
Prevent any API requests on accounts that are in deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 committed Nov 7, 2024
1 parent a6265b1 commit 3573584
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/api/keppel/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ func (a *API) handlePutAccount(w http.ResponseWriter, r *http.Request) {
http.Error(w, `malformed attribute "account.name" in request body is not allowed here`, http.StatusUnprocessableEntity)
return
}
// ... transfer it here into the struct, to make the below code simpler
// ... or state ...
if req.Account.State != "" {
http.Error(w, `malformed attribute "account.state" in request body is not allowed here`, http.StatusUnprocessableEntity)
return
}
// ... and transfer the name here into the struct, to make the below code simpler
req.Account.Name = models.AccountName(mux.Vars(r)["account"])

// check permission to create account
Expand Down
4 changes: 4 additions & 0 deletions internal/api/keppel/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ func (a *API) findAccountFromRequest(w http.ResponseWriter, r *http.Request, _ *
http.Error(w, "account not found", http.StatusNotFound)
return nil
}
if account.IsDeleting && r.Method == http.MethodGet {
http.Error(w, "account is being deleted", http.StatusConflict)
return nil
}
return account
}

Expand Down

0 comments on commit 3573584

Please sign in to comment.