fix: wrong message "account X has no access" in case of expired session
Massimo Melina committed
May 26, 2024 at 19:51 UTC
e0dc98e2c8bd05282954a4c525ca070f817a6275
1 file changed
+5
-2
frontend/src/useFetchList.ts
+5
-2
@@ -2,7 +2,7 @@
2
3
import { DirEntry, DirList, state, useSnapState } from './state'
4
import { useEffect, useRef } from 'react'
5
-import { apiEvents } from '@hfs/shared/api'
5
+import { apiCall, apiEvents } from '@hfs/shared/api'
6
import _ from 'lodash'
7
import { subscribeKey } from 'valtio/utils'
8
import { useIsMounted } from 'usehooks-ts'
@@ -91,7 +91,10 @@ export default function useFetchList() {
91
state.stopSearch?.()
92
state.error = xlate(error, HTTP_MESSAGES)
93
if (error === HTTP_UNAUTHORIZED && snap.username)
94
- void alertDialog(t('wrong_account', { u: snap.username }, "Account {u} has no access, try another"), 'warning')
94
+ apiCall('refresh_session').then(x => {
95
+ if (x.username) // check if username was actually considered (or instead session was refused)
96
+ void alertDialog(t('wrong_account', { u: snap.username }, "Account {u} has no access, try another"), 'warning')
97
+ })
98
state.loginRequired = error === HTTP_UNAUTHORIZED
99
lastReq.current = null
100
continue