Skip to content

API key rotation at /api/key-v2 doesn't display new key and page refresh re-rotates #14933

@svader0

Description

@svader0

Bug description

When working on #14932, I noticed that whenever I went into the user-dropdown and selected "API v2 key" and selected "generate new key", the key doesn't appear on the page. I tried to refresh, but the 'generate new key' request just gets sent again, so the key is still not visible. Instead, I have to reselect the dropdown and re-navigate. This is unintuitive. In other words, there are two main problems:

  1. Click "Generate New Key" button -> success banner shows, but key field renders empty.
  2. Browser refresh resubmits form and generates yet another key.

Given approval, I would be happy to submit a short PR to fix this issue. I expect that a solution would involve a redirect after a successful token reset to the same view.

Steps to reproduce

  1. Log into DefectDojo (either new or classic UI)
  2. Select user-dropdown in the top-right
  3. Select 'API v2 Key'
  4. Select 'Generate New Key'
  5. The key should not be present until you select the dropdown button again. A refresh should re-POST the token refresh request.

Expected behavior
As soon as I clicked 'Generate New Key' I expected to be presented with my new key.

Deployment method (select with an X)

  • Docker Compose
  • Kubernetes
  • GoDojo

Environment information

Running DD version v. 2.59.0-dev
Docker compose deployment
On Firefox 149.0.2 (64-bit) for Fedora Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions