@@ -144,7 +144,7 @@ import { commonMessages, injectNotificationManager } from '@modrinth/ui'
144144import { IntlFormatted } from ' @vintl/vintl/components'
145145
146146import HCaptcha from ' @/components/ui/HCaptcha.vue'
147- import { getAuthUrl } from ' @/composables/auth.js'
147+ import { getAuthUrl , getLauncherRedirectUrl } from ' @/composables/auth.js'
148148
149149const { addNotification } = injectNotificationManager ()
150150const { formatMessage } = useVIntl ()
@@ -275,26 +275,21 @@ async function finishSignIn(token) {
275275 token = auth .value .token
276276 }
277277
278- const usesLocalhostRedirectionScheme =
279- [' 4' , ' 6' ].includes (route .query .ipver ) && Number (route .query .port ) < 65536
278+ const redirectUrl = ` ${ getLauncherRedirectUrl (route)} /?code=${ token} `
280279
281- const redirectUrl = usesLocalhostRedirectionScheme
282- ? ` http:// ${ route . query . ipver === ' 4 ' ? ' 127.0.0.1 ' : ' [::1] ' } : ${ route . query . port } /?code= ${ token } `
283- : ` https://launcher-files.modrinth.com/?code= ${ token } `
284-
285- if (usesLocalhostRedirectionScheme) {
286- // When using this redirection scheme , the auth token is very visible in the URL to the user.
280+ if ( redirectUrl . startsWith ( ' https://launcher-files.modrinth.com/ ' )) {
281+ await navigateTo (redirectUrl, {
282+ external : true ,
283+ })
284+ } else {
285+ // When redirecting to localhost , the auth token is very visible in the URL to the user.
287286 // While we could make it harder to find with a POST request, such is security by obscurity:
288287 // the user and other applications would still be able to sniff the token in the request body.
289288 // So, to make the UX a little better by not changing the displayed URL, while keeping the
290289 // token hidden from very casual observation and keeping the protocol as close to OAuth's
291290 // standard flows as possible, let's execute the redirect within an iframe that visually
292291 // covers the entire page.
293292 subtleLauncherRedirectUri .value = redirectUrl
294- } else {
295- await navigateTo (redirectUrl, {
296- external: true ,
297- })
298293 }
299294
300295 return
0 commit comments