From e368e35e74caad8b033caa78479f86ff63689c31 Mon Sep 17 00:00:00 2001 From: Erb3 <49862976+Erb3@users.noreply.github.com> Date: Wed, 29 Jan 2025 03:51:41 +0100 Subject: [PATCH] fix(frontend): finish auth when redirect URI is supplied (#3191) - Fixes #3188 - Refactors if-else statement into ternary --- apps/frontend/src/composables/auth.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/apps/frontend/src/composables/auth.js b/apps/frontend/src/composables/auth.js index ea2505090..978a4d844 100644 --- a/apps/frontend/src/composables/auth.js +++ b/apps/frontend/src/composables/auth.js @@ -104,22 +104,15 @@ export const initAuth = async (oldToken = null) => { return auth; }; -export const getAuthUrl = (provider, redirect = "") => { +export const getAuthUrl = (provider, redirect = "/dashboard") => { const config = useRuntimeConfig(); const route = useNativeRoute(); - if (redirect === "") { - redirect = route.path; - } + const fullURL = route.query.launcher + ? "https://launcher-files.modrinth.com" + : `${config.public.siteUrl}/auth/sign-in?redirect=${redirect}`; - let fullURL; - if (route.query.launcher) { - fullURL = `https://launcher-files.modrinth.com`; - } else { - fullURL = `${config.public.siteUrl}${redirect}`; - } - - return `${config.public.apiBaseUrl}auth/init?provider=${provider}&url=${fullURL}`; + return `${config.public.apiBaseUrl}auth/init?provider=${provider}&url=${encodeURIComponent(fullURL)}`; }; export const removeAuthProvider = async (provider) => {