Skip to content

Commit

Permalink
fix(frontend): finish auth when redirect URI is supplied (#3191)
Browse files Browse the repository at this point in the history
- Fixes #3188
- Refactors if-else statement into ternary
  • Loading branch information
Erb3 authored Jan 29, 2025
1 parent 1e09305 commit e368e35
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions apps/frontend/src/composables/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

let fullURL;
if (route.query.launcher) {
fullURL = `https://launcher-files.modrinth.com`;
} else {
fullURL = `${config.public.siteUrl}${redirect}`;
}
const fullURL = route.query.launcher
? "https://launcher-files.modrinth.com"
: `${config.public.siteUrl}/auth/sign-in?redirect=${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) => {
Expand Down

0 comments on commit e368e35

Please sign in to comment.