Skip to content

Commit

Permalink
Merge branch '68-reader-role' of github.com:equinor/radix-api into 68…
Browse files Browse the repository at this point in the history
…-reader-role
  • Loading branch information
anneliawa committed Jul 18, 2023
2 parents 3ae7e38 + b01ceb9 commit 58bec98
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions api/applications/applications_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,11 @@ func (ah *ApplicationHandler) ModifyRegistrationDetails(ctx context.Context, app

// DeleteApplication handler for DeleteApplication
func (ah *ApplicationHandler) DeleteApplication(ctx context.Context, appName string) error {
// Make check that this is an existing application and that the user has access to it
userAccount := ah.getUserAccount()
userIsAdmin, err := ah.authorizationValidator.UserIsAdmin(ctx, &userAccount, appName)
// Make check that this is an existing application
_, err := ah.getUserAccount().RadixClient.RadixV1().RadixRegistrations().Get(ctx, appName, metav1.GetOptions{})
if err != nil {
return err
}
if !userIsAdmin {
return fmt.Errorf("user is not allowed to delete registration %s", appName)
}

err = ah.getUserAccount().RadixClient.RadixV1().RadixRegistrations().Delete(ctx, appName, metav1.DeleteOptions{})
if err != nil {
Expand Down

0 comments on commit 58bec98

Please sign in to comment.