@@ -12,6 +12,12 @@ interface VersionAlertPayload {
1212 version? : string ;
1313}
1414
15+ interface VersionMessageResponse {
16+ status: number ;
17+ data: string ;
18+ success: boolean ;
19+ }
20+
1521const props = defineProps <{ collapse: boolean }>();
1622
1723const recentSiteLimit = 5 ;
@@ -309,17 +315,17 @@ const handleClearInput = () => {
309315 recentSitesDismissed .value = false ;
310316};
311317
312- function normalizeVersionMessage(raw : string ) {
313- if (raw === " incompatible " ) {
318+ function normalizeVersionMessage(response : VersionMessageResponse ) {
319+ if (response . status === 404 ) {
314320 return { status: " incompatible" as const , versions: [] as string [] };
315321 }
316322
317- if (! raw ) {
323+ if (! response . data ) {
318324 return { status: " list" as const , versions: [] as string [] };
319325 }
320326
321327 try {
322- const parsed = JSON .parse (raw );
328+ const parsed = JSON .parse (response . data );
323329 const versions = Array .isArray (parsed )
324330 ? parsed .map ((item ) => (item == null ? " " : String (item ))).filter ((v ) => v .length > 0 )
325331 : [];
@@ -361,13 +367,33 @@ const emitVersionAlertAndCloseModal = (payload: VersionAlertPayload) => {
361367 useEventBus ().emit (" versionAlert" , payload );
362368};
363369
370+ const handleInvalidSiteVersion = () => {
371+ clearLoginBtnUnlockTimer ();
372+ loginBtn .value = false ;
373+ hasValidationError .value = true ;
374+ errorMessage .value = t (" Login.InvalidSiteError" );
375+
376+ void useTauriCoreInvoke (" auth_cancel" , {});
377+
378+ nextTick (() => {
379+ inputRef .value ?.$el ?.querySelector (" input" )?.focus ();
380+ });
381+ };
382+
364383const checkVersionBeforeOAuth = async (site : string ) => {
365- const [rawVersionMessage, appVersion] = await Promise .all ([
366- useTauriCoreInvoke <string >(" get_version_message" , { site }).catch (() => " " ),
384+ const [versionResponse, appVersion] = await Promise .all ([
385+ useTauriCoreInvoke <VersionMessageResponse >(" get_version_message" , { site }).catch ((error ) => {
386+ return null ;
387+ }),
367388 useTauriAppGetVersion ().catch (() => " " )
368389 ]);
369390
370- const { status : versionStatus, versions } = normalizeVersionMessage (rawVersionMessage );
391+ if (! versionResponse || versionResponse .status === 0 ) {
392+ handleInvalidSiteVersion ();
393+ return false ;
394+ }
395+
396+ const { status : versionStatus, versions } = normalizeVersionMessage (versionResponse );
371397
372398 if (versionStatus === " incompatible" ) {
373399 emitVersionAlertAndCloseModal ({ type: " incompatible" });
@@ -621,7 +647,7 @@ onMounted(async () => {
621647 let description = message || t (" Login.LoginFailedErrorPage" );
622648
623649 if (reason === " invalid-site" ) {
624- description = t (" Login.InvalidSiteError " );
650+ description = t (" " );
625651 }
626652
627653 toast .add ({
0 commit comments