-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upcoming: [M3-7716] - Add session expiry confirmation dialog for proxy users #10152
Conversation
isSideMenuOpen={!desktopMenuIsOpen} | ||
openSideMenu={() => toggleMenu(true)} | ||
username={username} | ||
<SwitchAccountSessionProvider value={switchAccountSessionContextValue}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only change here was adding the Provider wrapper (rest is context shift)
() => setState((prevState) => ({ ...prevState, isOpen: true })), | ||
[] | ||
); | ||
const close = useCallback( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added TODO since open
and close
are no longer necessary, but I didn't want to break existing API.
[key: string]: boolean; | ||
}; | ||
|
||
export const defaultContext: DialogContextProps = { | ||
close: () => void 0, | ||
isOpen: false, | ||
open: () => void 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll be able to remove these 3 as well in upcoming PR
} | ||
}, [isParentTokenExpired, sessionContext]); | ||
|
||
return { isParentTokenExpired }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open to input/thoughts here
Coverage Report: ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/manager/src/features/Account/SwitchAccounts/useParentTokenManagement.tsx
Outdated
Show resolved
Hide resolved
The goal was to prevent users from attempting to switch accounts once the token expired - so the |
@jaalah What if we don't disable the Switch Account button at expiry but just have it open the session expiry confirmation dialog instead? That way the dialog doesn't display when the user isn't trying to switch accounts but still prevents users from switching accounts |
@hana-linode 🙌 reviewupdates.mp4 |
I'm keeping things in context because we're going to implement a way to refresh parent tokens as expiry nears an end, so I'll swap the dialog and save me some work. |
Liking this flow a lot better. I was thinking we can keep the Switch Account buttons enabled even after the user hits close. And just keep having the button open the session expiry confirmation dialog until they re-login to the parent account Screen.Recording.2024-02-09.at.11.02.09.AM.mov |
Hmm, I agree with this too. We're currently doing a bit of both flows when we only disable after the first click of the button/appearance of the dialog, which feels like an odd UX. It'd be more consistent to either (1) always allow the user to click the enabled button and see the modal or (2) always disable the buttons, which was the original behavior but I think Hana's suggestion is better -- less intrusive for the user. A minor note: if the parent token is expired and if the parent profile request is not cached, then we might end up with the parent username no longer displaying in the user menu above the company name. |
@hana-linode @mjac0bs ✅ thanks for feedback! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the changes - the expiry dialog looks good and is displayed for a proxy user clicking either Switch Account button who doesn't have a valid parent token in local storage.
Left a few comments about minor clean up - mostly related to naming, a couple related to the tooltip we were displaying when disabling the button.
packages/manager/.changeset/pr-10152-upcoming-features-1707246537679.md
Outdated
Show resolved
Hide resolved
packages/manager/src/features/Account/SwitchAccounts/useParentTokenManagement.tsx
Show resolved
Hide resolved
…537679.md Co-authored-by: Mariah Jacobs <114685994+mjac0bs@users.noreply.github.com>
Co-authored-by: Mariah Jacobs <114685994+mjac0bs@users.noreply.github.com>
Description 📝
When a proxy user wants to switch back to their parent account, the parent account's authentication token must still be valid in order for them to switch back to the parent's account or log into any other proxy accounts displayed in the drawer.
If the parent token is not valid, a proxy user should be given adequate notice that they must re-log in to the parent account. We also will disabled the "Switch Account" buttons if this is the case.
Changes 🔄
useDialogContext.ts
hook API. The original API was kind of rigid, whereas now we can have dynamic state that we can extend if we need to. The original API and references toopen
andclosed
still work, but I will clean that up after this PR.SwitchAccountSessionDialog.tsx
for when parent session expiresuseParentTokenManagement.tsx
for checking expiration and showing dialog. We still may need to poll the expiry or at least check every time the user menu opens or a user lands on the account page.isRestrictedGlobalGrantType
to take into considerationaccount_access
which can benull | 'read_only' | 'read_write'
Preview 📷
How to test 🧪
Should NOT show session expired dialog
Prerequisites
parent
user, if not, update: serverHandlersReproduction steps
Verification steps
user_type
toproxy
in serverHandlersShould show session expired dialog
Prerequisites
user_type
toproxy
in serverHandlersReproduction steps
Verification steps
As an Author I have considered 🤔
Check all that apply