Skip to content
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

fix: Call showOauthClientsLimitExceeded only when Cookie exists #956

Merged
merged 3 commits into from
Sep 28, 2023

Conversation

Ldoppea
Copy link
Member

@Ldoppea Ldoppea commented Sep 28, 2023

When showing OauthClientsLimitExceeded we should ensure that a Session Cookie is set on the app

If not, the popup will display a cozy-stack error

After the login scenario, when cozy-home does its first render, then no Session Cookie exist yet. In that case we should call getIndexHtmlForSlug at least once to generate the Session Cookie

So in that case we want to call showOauthClientsLimitExceeded only after getIndexHtmlForSlug

But if a Session Cookie exists, then we want to continue doing the check before calling getIndexHtmlForSlug so we prevent unnecessary getIndexHtmlForSlug calls (this queries cozy-stack) when OauthClientsLimit is exceeded and when the Session Cookie exists

When showing OauthClientsLimitExceeded we should ensure that a Session
Cookie is set on the app

If not, the popup will display a cozy-stack error

After the login scenario, when cozy-home does its first render, then no
Session Cookie exist yet. In that case we should call
`getIndexHtmlForSlug` at least once to generate the Session Cookie

So in that case we want to call `showOauthClientsLimitExceeded` only
after `getIndexHtmlForSlug`

But if a Session Cookie exists, then we want to continue doing the
check before calling `getIndexHtmlForSlug` so we prevent unnecessary
`getIndexHtmlForSlug` calls (this queries cozy-stack) when
OauthClientsLimit is exceeded and when the Session Cookie exists
@Ldoppea Ldoppea force-pushed the fix/oauth_limit_not_connected branch from 29c0108 to d64f725 Compare September 28, 2023 11:08
if (isOauthClientsLimitExeeded) {
if (slug === 'home') {
showOauthClientsLimitExceeded(href)
return false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to render the home even if oauth clients limit is exceeded ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the home will be rendered behind the pop so it won't be visible by the user

We do this to improve user experience so when they fix the number of OAuth client, they will instantaneously go to the home (as it is already loaded)

More generally, we try to always have the homeView loaded for this reason (except when no user is logged)

Note that we do this for the HomeView because it has its own container. We cannot do this for cozy-app because one container is used for all cozy-app, so for example we cannot keep drive and mespapiers loaded simultaneously. But if we could we would have done it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the explanation!

@Ldoppea Ldoppea merged commit 0e5c007 into master Sep 28, 2023
2 checks passed
@Ldoppea Ldoppea deleted the fix/oauth_limit_not_connected branch September 28, 2023 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants