fix(frontend): finish auth when redirect URI is supplied (#3191)

- Fixes #3188
- Refactors if-else statement into ternary
This commit is contained in:
Erb3 2025-01-29 03:51:41 +01:00 committed by GitHub
parent 1e09305fb3
commit e368e35e74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) => {