Skip to content

Commit

Permalink
fix: use default locale on failed oauth remote connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Mar 15, 2024
1 parent 3864b02 commit daf3b92
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,18 @@ def get_preferences(self, username):
openedx_apis = current_app.config["OPENEDX_API_URLS"]
url = openedx_apis["get_preference"].format(username=username)
oauth_remote = self.oauth_remotes.get("openedxsso")
response = oauth_remote.get(url, token=self.get_oauth_token()).json()
locale_preference = response.get("pref-lang", "en").replace("-", "_")
locale_preference = "en"
try:
response = oauth_remote.get(url, token=self.get_oauth_token()).json()
locale_preference = response.get("pref-lang", "en").replace("-", "_")
except Exception as e:
return locale_preference

if locale_preference not in current_app.config["DASHBOARD_LOCALES"]:
log.warning(
f"Language {locale_preference} is not supported by Superset"
)
locale_preference = "en"
log.warning(
f"Language {locale_preference} is not supported by Superset"
)
return locale_preference

return locale_preference

Expand Down

0 comments on commit daf3b92

Please sign in to comment.