-
Notifications
You must be signed in to change notification settings - Fork 213
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
(feat) O3-2484: The application should revert to default locale on logout #782
Conversation
Size Change: +203 B (0%) Total Size: 2.84 MB
ℹ️ View Unchanged
|
}, | ||
}); | ||
}); | ||
it("should render Logout and redirect to login page ig provider.type !== oauth2", async () => { |
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.
it("should render Logout and redirect to login page ig provider.type !== oauth2", async () => { | |
it("should render Logout and redirect to login page if provider.type !== oauth2", async () => { |
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.
I don't think the if provider.type !== oauth2
is informative or useful here. If we need something here, it might be better to say by default
.
Basically, I don't think our test descriptions should hard-code the assumption that the only provider.types
are "default" or "oauth2".
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.
@ibacher Could you take another look at this part and see if it makes sense to you? I don't know anything about provider type and oauth.
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.
I'm happy with the new test name.
How I'm thinking about this is there: there are various forms of SSO protocols (Kerberos, SAML, OIDC—which is what we're calling OAuth2) with slightly different mechanisms for communicating between the authentication server and the resource server (which is the role OpenMRS plays in any configuration). The provider
attribute allows us to customize the way the login app works based on the expected authentication server type.
Currently, we only really have two modes: OpenMRS base authentication and OAuth2 (which is, at least OIDC-like), but it's helpful to have it be treated as more than just a binary value.
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.
Nice, and thanks for the explanation!
@@ -1,5 +1,5 @@ | |||
<!DOCTYPE html> | |||
<html lang="<%= openmrsDefaultLocale %>"> | |||
<html lang="<%= openmrsDefaultLocale %>" defaultLang="<%= openmrsDefaultLocale %>"> |
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.
<html lang="<%= openmrsDefaultLocale %>" defaultLang="<%= openmrsDefaultLocale %>"> | |
<html lang="<%= openmrsDefaultLocale %>" data-default-lang="<%= openmrsDefaultLocale %>"> |
Custom attributes must be prefixed.
@@ -19,6 +20,13 @@ const RedirectLogout: React.FC<RedirectLogoutProps> = () => { | |||
navigate({ to: "${openmrsSpaBase}/login" }); | |||
} else { | |||
performLogout().then(() => { | |||
const defaultLang = | |||
document.documentElement.getAttribute("defaultLang"); |
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.
document.documentElement.getAttribute("defaultLang"); | |
document.documentElement.getAttribute("data-default-lang"); |
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.
Shouldn't we just be using the lang
attribute for this?
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.
The trouble is that the lang
attribute gets updated with the user preference. That attribute is supposed to be set to the current language of that page. We need a way of storing the default language, which is passed in to the app shell and becomes an ejs parameter. I imagine there is also a way of obtaining the default without rendering it into the HTML. But I think this way of doing it is fine.
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.
Yeah, ok, that makes sense.
Everything LGTM other than the |
const defaultLang = | ||
document.documentElement.getAttribute("data-default-lang"); | ||
setUserLanguage({ | ||
locale: defaultLang, | ||
authenticated: false, | ||
sessionId: "", | ||
}); |
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.
It might be better to make this part of the performLogout()
or even the logic that happens here, which might solve similar issues (for instance, when a user's session times out, should the language be reset? If yes, it probably belongs in the refetchCurrentUser()
logic), but this is only a suggestion.
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.
Right @ibacher , I'll look into that too.
Thanks!
@brandones , the changes are requested by you, can you approve the PR too? |
Requirements
For changes to apps
If applicable
Summary
For an application having the default locale other than
en
(say 'km'), if the logged in user changes the locale toen
, after the logout, the application's locale is set toen
, instead ofkm
. This PR resets the application to the default locale on logout.Screenshots
Screen.Recording.2023-10-06.at.12.54.39.mov
Related Issue
https://issues.openmrs.org/projects/O3/issues/O3-2484
Other