Skip to content

Commit

Permalink
fix: Handle invalid locale
Browse files Browse the repository at this point in the history
  • Loading branch information
seriaati committed Oct 17, 2024
1 parent 46ef9e0 commit b8b2e71
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hoyo_buddy/web_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,11 @@ async def _handle_login_routes(self, route: str, parsed_params: dict[str, str])

if route == "/login":
user_data = await self.fetch_user_data()
return pages.LoginPage(user_data, translator=self._translator, locale=Locale(locale))
try:
locale_ = Locale(locale)
except ValueError:
return pages.ErrorPage(code=422, message="Invalid locale")
return pages.LoginPage(user_data, translator=self._translator, locale=locale_)

if route == "/geetest":
query: str | None = await page.client_storage.get_async(f"hb.{parsed_params['user_id']}.params")
Expand Down

0 comments on commit b8b2e71

Please sign in to comment.