Skip to content

Commit

Permalink
On logout, the default locale of the application should override the …
Browse files Browse the repository at this point in the history
…user's locale
  • Loading branch information
vasharma05 committed Oct 6, 2023
1 parent 82616de commit ffb6690
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect } from "react";
import {
navigate,
setUserLanguage,
useConfig,
useConnectivity,
useSession,
Expand All @@ -19,6 +20,13 @@ const RedirectLogout: React.FC<RedirectLogoutProps> = () => {
navigate({ to: "${openmrsSpaBase}/login" });
} else {
performLogout().then(() => {
const defaultLang =
document.documentElement.getAttribute("defaultLang");
setUserLanguage({
locale: defaultLang,
authenticated: false,
sessionId: "",
});
if (config.provider.type === "oauth2") {
navigate({ to: config.provider.logoutUrl });
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function isValidLocale(locale: unknown): locale is string {
return true;
}

function setUserLanguage(data: Session) {
export function setUserLanguage(data: Session) {
const locale = data?.user?.userProperties?.defaultLocale ?? data.locale;
const htmlLang = document.documentElement.getAttribute("lang");

Expand Down
2 changes: 1 addition & 1 deletion packages/shell/esm-app-shell/src/index.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="<%= openmrsDefaultLocale %>">
<html lang="<%= openmrsDefaultLocale %>" defaultLang="<%= openmrsDefaultLocale %>">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand Down

0 comments on commit ffb6690

Please sign in to comment.