You've already forked AstralRinth
forked from didirus/AstralRinth
Merge commit '2cfb637451441e5bd51dbfb736598ee33b7e8323' into feature-clean
This commit is contained in:
@@ -111,7 +111,13 @@ export const getAuthUrl = (provider, redirect = "") => {
|
||||
if (redirect === "") {
|
||||
redirect = route.path;
|
||||
}
|
||||
const fullURL = `${config.public.siteUrl}${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}`;
|
||||
};
|
||||
|
||||
1
apps/frontend/src/layouts/empty.vue
Normal file
1
apps/frontend/src/layouts/empty.vue
Normal file
@@ -0,0 +1 @@
|
||||
<template><slot id="main" /></template>
|
||||
5
apps/frontend/src/middleware/launcher-auth.ts
Normal file
5
apps/frontend/src/middleware/launcher-auth.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export default defineNuxtRouteMiddleware((to) => {
|
||||
if (to.query.launcher) {
|
||||
setPageLayout("empty");
|
||||
}
|
||||
});
|
||||
@@ -1,3 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
definePageMeta({
|
||||
middleware: ["launcher-auth"],
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<NuxtPage class="auth-container universal-card" />
|
||||
</template>
|
||||
|
||||
@@ -94,12 +94,24 @@
|
||||
<div class="auth-form__additional-options">
|
||||
<IntlFormatted :message-id="messages.additionalOptionsLabel">
|
||||
<template #forgot-password-link="{ children }">
|
||||
<NuxtLink class="text-link" to="/auth/reset-password">
|
||||
<NuxtLink
|
||||
class="text-link"
|
||||
:to="{
|
||||
path: '/auth/reset-password',
|
||||
query: route.query,
|
||||
}"
|
||||
>
|
||||
<component :is="() => children" />
|
||||
</NuxtLink>
|
||||
</template>
|
||||
<template #create-account-link="{ children }">
|
||||
<NuxtLink class="text-link" :to="signUpLink">
|
||||
<NuxtLink
|
||||
class="text-link"
|
||||
:to="{
|
||||
path: '/auth/sign-up',
|
||||
query: route.query,
|
||||
}"
|
||||
>
|
||||
<component :is="() => children" />
|
||||
</NuxtLink>
|
||||
</template>
|
||||
@@ -193,10 +205,6 @@ const token = ref("");
|
||||
|
||||
const flow = ref(route.query.flow);
|
||||
|
||||
const signUpLink = computed(
|
||||
() => `/auth/sign-up${route.query.redirect ? `?redirect=${route.query.redirect}` : ""}`,
|
||||
);
|
||||
|
||||
async function beginPasswordSignIn() {
|
||||
startLoading();
|
||||
try {
|
||||
@@ -252,6 +260,11 @@ async function begin2FASignIn() {
|
||||
}
|
||||
|
||||
async function finishSignIn(token) {
|
||||
if (route.query.launcher) {
|
||||
await navigateTo(`https://launcher-files.modrinth.com/?code=${token}`, { external: true });
|
||||
return;
|
||||
}
|
||||
|
||||
if (token) {
|
||||
await useAuth(token);
|
||||
await useUser();
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
:description="formatMessage(messages.subscribeLabel)"
|
||||
/>
|
||||
|
||||
<p>
|
||||
<p v-if="!route.query.launcher">
|
||||
<IntlFormatted :message-id="messages.legalDisclaimer">
|
||||
<template #terms-link="{ children }">
|
||||
<NuxtLink to="/legal/terms" class="text-link">
|
||||
@@ -118,7 +118,13 @@
|
||||
|
||||
<div class="auth-form__additional-options">
|
||||
{{ formatMessage(messages.alreadyHaveAccountLabel) }}
|
||||
<NuxtLink class="text-link" :to="signInLink">
|
||||
<NuxtLink
|
||||
class="text-link"
|
||||
:to="{
|
||||
path: '/auth/sign-in',
|
||||
query: route.query,
|
||||
}"
|
||||
>
|
||||
{{ formatMessage(commonMessages.signInButton) }}
|
||||
</NuxtLink>
|
||||
</div>
|
||||
@@ -214,10 +220,6 @@ const confirmPassword = ref("");
|
||||
const token = ref("");
|
||||
const subscribe = ref(true);
|
||||
|
||||
const signInLink = computed(
|
||||
() => `/auth/sign-in${route.query.redirect ? `?redirect=${route.query.redirect}` : ""}`,
|
||||
);
|
||||
|
||||
async function createAccount() {
|
||||
startLoading();
|
||||
try {
|
||||
@@ -245,6 +247,13 @@ async function createAccount() {
|
||||
},
|
||||
});
|
||||
|
||||
if (route.query.launcher) {
|
||||
await navigateTo(`https://launcher-files.modrinth.com/?code=${res.session}`, {
|
||||
external: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await useAuth(res.session);
|
||||
await useUser();
|
||||
|
||||
|
||||
@@ -266,6 +266,7 @@ import {
|
||||
import DOMPurify from "dompurify";
|
||||
import { ButtonStyled } from "@modrinth/ui";
|
||||
import { refThrottled } from "@vueuse/core";
|
||||
import { Intercom, shutdown } from "@intercom/messenger-js-sdk";
|
||||
import type { ServerState, Stats, WSEvent, WSInstallationResultEvent } from "~/types/servers";
|
||||
|
||||
const socket = ref<WebSocket | null>(null);
|
||||
@@ -275,6 +276,19 @@ const reconnectInterval = ref<ReturnType<typeof setInterval> | null>(null);
|
||||
const isFirstMount = ref(true);
|
||||
const isMounted = ref(true);
|
||||
|
||||
const INTERCOM_APP_ID = ref("ykeritl9");
|
||||
const auth = await useAuth();
|
||||
// @ts-expect-error - Auth is untyped
|
||||
const userId = ref(auth.value?.user?.id ?? null);
|
||||
// @ts-expect-error - Auth is untyped
|
||||
const username = ref(auth.value?.user?.username ?? null);
|
||||
// @ts-expect-error - Auth is untyped
|
||||
const email = ref(auth.value?.user?.email ?? null);
|
||||
const createdAt = ref(
|
||||
// @ts-expect-error - Auth is untyped
|
||||
auth.value?.user?.created ? Math.floor(new Date(auth.value.user.created).getTime() / 1000) : null,
|
||||
);
|
||||
|
||||
const route = useNativeRoute();
|
||||
const router = useRouter();
|
||||
const serverId = route.params.id as string;
|
||||
@@ -735,6 +749,8 @@ const openInstallLog = () => {
|
||||
const cleanup = () => {
|
||||
isMounted.value = false;
|
||||
|
||||
shutdown();
|
||||
|
||||
stopPolling();
|
||||
stopUptimeUpdates();
|
||||
if (reconnectInterval.value) {
|
||||
@@ -774,6 +790,27 @@ onMounted(() => {
|
||||
connectWebSocket();
|
||||
}
|
||||
|
||||
if (username.value && email.value && userId.value && createdAt.value) {
|
||||
const currentUser = auth.value?.user as any;
|
||||
const matches =
|
||||
username.value === currentUser?.username &&
|
||||
email.value === currentUser?.email &&
|
||||
userId.value === currentUser?.id &&
|
||||
createdAt.value === Math.floor(new Date(currentUser?.created).getTime() / 1000);
|
||||
|
||||
if (matches) {
|
||||
Intercom({
|
||||
app_id: INTERCOM_APP_ID.value,
|
||||
userId: userId.value,
|
||||
name: username.value,
|
||||
email: email.value,
|
||||
created_at: createdAt.value,
|
||||
});
|
||||
} else {
|
||||
console.warn("[PYROSERVERS][INTERCOM] mismatch");
|
||||
}
|
||||
}
|
||||
|
||||
DOMPurify.addHook(
|
||||
"afterSanitizeAttributes",
|
||||
(node: {
|
||||
|
||||
@@ -103,23 +103,6 @@
|
||||
origin: "https://modrinth.com",
|
||||
});
|
||||
});
|
||||
|
||||
let attempts = 0;
|
||||
function syncAgreeState() {
|
||||
const primaryButton = document.querySelector(
|
||||
".qc-cmp2-summary-buttons button:last-of-type",
|
||||
);
|
||||
|
||||
if (primaryButton) {
|
||||
primaryButton.click();
|
||||
} else {
|
||||
attempts++;
|
||||
if (attempts < 10) {
|
||||
setTimeout(syncAgreeState, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
syncAgreeState();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user