@@ -61,9 +61,10 @@ import { renderString } from '@modrinth/utils'
61
61
import { useFetch } from ' @/helpers/fetch.js'
62
62
import { check } from ' @tauri-apps/plugin-updater'
63
63
import NavButton from ' @/components/ui/NavButton.vue'
64
- import { get as getCreds , login , logout } from ' @/helpers/mr_auth.js'
64
+ import { cancelLogin , get as getCreds , login , logout } from ' @/helpers/mr_auth.js'
65
65
import { get_user } from ' @/helpers/cache.js'
66
66
import AppSettingsModal from ' @/components/ui/modal/AppSettingsModal.vue'
67
+ import AuthGrantFlowWaitModal from ' @/components/ui/modal/AuthGrantFlowWaitModal.vue'
67
68
import PromotionWrapper from ' @/components/ui/PromotionWrapper.vue'
68
69
import { hide_ads_window , init_ads_window } from ' @/helpers/ads.js'
69
70
import FriendsList from ' @/components/ui/friends/FriendsList.vue'
@@ -263,6 +264,8 @@ const incompatibilityWarningModal = ref()
263
264
264
265
const credentials = ref ()
265
266
267
+ const modrinthLoginFlowWaitModal = ref ()
268
+
266
269
async function fetchCredentials () {
267
270
const creds = await getCreds ().catch (handleError)
268
271
if (creds && creds .user_id ) {
@@ -272,8 +275,24 @@ async function fetchCredentials() {
272
275
}
273
276
274
277
async function signIn () {
275
- await login ().catch (handleError)
276
- await fetchCredentials ()
278
+ modrinthLoginFlowWaitModal .value .show ()
279
+
280
+ try {
281
+ await login ()
282
+ await fetchCredentials ()
283
+ } catch (error) {
284
+ if (
285
+ typeof error === ' object' &&
286
+ typeof error[' message' ] === ' string' &&
287
+ error .message .includes (' Login canceled' )
288
+ ) {
289
+ // Not really an error due to being a result of user interaction, show nothing
290
+ } else {
291
+ handleError (error)
292
+ }
293
+ } finally {
294
+ modrinthLoginFlowWaitModal .value .hide ()
295
+ }
277
296
}
278
297
279
298
async function logOut () {
@@ -402,6 +421,9 @@ function handleAuxClick(e) {
402
421
< Suspense>
403
422
< AppSettingsModal ref= " settingsModal" / >
404
423
< / Suspense>
424
+ < Suspense>
425
+ < AuthGrantFlowWaitModal ref= " modrinthLoginFlowWaitModal" @flow- cancel= " cancelLogin" / >
426
+ < / Suspense>
405
427
< Suspense>
406
428
< InstanceCreationModal ref= " installationModal" / >
407
429
< / Suspense>
0 commit comments