openfoodnetwork icon indicating copy to clipboard operation
openfoodnetwork copied to clipboard

Let users view and regenerates api key

Open Philwi opened this issue 2 years ago • 2 comments

What? Why?

Closes #9166

Only admin users can generate and see API keys at the moment. So if anyone wants to use the API they need to ask an instance manager for an API key first.

Now an admin can toggle the appearance for every user the developer settings tab in /account. A user can now see and copy their API key or regenerate a new one.

What should we test?

  • visit /admin/users

  • chose an user to edit

  • toggle the Checkbox: "Show API key generation view"

  • visit with the choosen the user /account

  • now there should be the developer settings tab depending if the checkbox "Show API key generation view" was checked or not

Release notes

Changelog Category: User facing changes

The title of the pull request will be included in the release notes.

Dependencies

Documentation updates

Philwi avatar Jul 16 '22 09:07 Philwi

@mkllnk I removed the update logic in the spree_user model. Unfortunately the logic for the generation of the spree_api_key is spread over the whole repository. So it isn't very DRY. Is there a place where it should be placed? Should I create a ServiceObject to encapsulate the logic?

Philwi avatar Jul 26 '22 20:07 Philwi

Great! I'll add another commit to make the spec a bit more precise but your spec is excellent already.

Yeah tt's now better readable, good to know! Thanks :)

Philwi avatar Aug 12 '22 09:08 Philwi

Hey again @Philwi ,

This is nice, thanks a bunch for implementing it.

The short video below goes through the what should we test steps - appreciate that you've for detailing them.

As a superadmin

  • visiting /admin/users
  • chose an user to edit
  • toggle the Checkbox: "Show API key generation view"

As the respective customer

  • visiting the /account#/ section
  • seeing the new "Developer Settings" tab
  • the API key is visible to the customer :tada: (it matches the key seen by the superadmin)
  • clicking "Regenerate Key" creates a new key (which matches the key seen by the superadmin)

Screencast from 17-08-2022 21:25:33.webm

Looks great.

The only glitch in this PR is perhaps the rendering of the new "Developer Settings" tab; When not limited by screen width it should appear beside "Account Settings". I don't think this should block merging this.

image

Let's merge, I'll create an issue and assign it to you @Philwi - please feel free to unassigned yourself if you're not available or prefer to work on something else.

Again, many thanks for this contribution :pray:

Merging.

filipefurtad0 avatar Aug 17 '22 20:08 filipefurtad0