openfoodnetwork
openfoodnetwork copied to clipboard
Let users view and regenerates api key
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
@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?
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 :)
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.
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.