@samitouri / QOSami-HFS / commits / 0382f9f0

fix: error "index of undefined" on login timeout

Massimo Melina committed Oct 9, 2024 at 10:12 UTC 0382f9f07fa71170c61b64ffc3faeabbf3eea9f1
2 files changed +3 -1
frontend/src/i18n.ts
+2
@@ -31,6 +31,8 @@ export function I18Nprovider({ embedded='en', ...props }) {
31
32 // If one of the keys is an "id", that should be the first. If one of the keys should work as a fallback, that should be the last. Use 'fallback' parameter if you don't want the fallback to work as a key.
33 export function t(keyOrTpl: string | string[] | TemplateStringsArray, params?: any, fallback?: string) {
34 + if (!keyOrTpl)
35 + return ''
36 // memoize?
37 const keys = isTemplateStringsArray(keyOrTpl) ? [(fallback ??= keyOrTpl[0] as string)]
38 : Array.isArray(keyOrTpl) ? keyOrTpl : [keyOrTpl]
frontend/src/login.ts
+1 -1
@@ -24,7 +24,7 @@ async function login(username:string, password:string, extra?: object) {
24 throw Error(err.message === 'trust' ? t('login_untrusted', "Login aborted: server identity cannot be trusted")
25 : err.code === HTTP_UNAUTHORIZED ? t('login_bad_credentials', "Invalid credentials")
26 : err.code === HTTP_CONFLICT ? t('login_bad_cookies', "Cookies not working - login failed")
27 - : t(err.message))
27 + : t(err.message || String(err)))
28 })
29 }
30