fix(admin): restore tokens
Description
This bug did not concern only the add relation action on group relations page but also the entire GUI. The problem was that during the execution of the MFA, access and refresh tokens were removed from local storage, what triggered an API call from the parent component (getGroupById
in this specific case). This call without tokens returned a 401 response status code. Subsequently, as a result of this error, angular killed the displayed component and started rendering it again. The data is automatically refreshed during rendering, but this refresh did not wait to complete the action call on BE. Therefore, a race condition occurred here, and sometimes, refresh obtained outdated data from the BE. The return value of the refresh call waiting for the completion of the create action on BE was not rendered in the GUI because this refresh was already started in a dead component.
Tokens are removed from local storage, but at the same time, they are stored in session storage so they can be set back if MFA is not successful. To fix this, we will restore them immediately. It should not break anything.
How to test
Deploy this branch on devel because if you run GUI locally, this bug doesn't exist there at all. Try some action like, for example, adding group relations on some critical group for the MFA to be requested. After completion, check that the relations table has been refreshed and contains current data.
Author's checklist
-
I have followed the contribution guidelines -
This MR has been tested or does not change functionality -
I have added relevant merge request dependencies (if this MR has any) -
I have added the correct labels -
I have assigned reviewers (if any are relevant) -
I have edited the documentation (if the changes require it) or I have noted the need for the change if I do not have access to the documentation -
I have marked all introduced BREAKING CHANGES or necessary DEPLOYMENT NOTES in the commit message(s)
Reviewer's checklist
-
This MR has been tested or does not change functionality -
This MR has correct commit message format
Related issues
Closes STR-1440