Friends system for app (#2958)

* Friends system for app

* Fix impl issues

* move friends to in-memory store
This commit is contained in:
Geometrically
2024-11-26 18:23:29 -07:00
committed by GitHub
parent 7184c5f5c7
commit 47b0ccdf78
46 changed files with 1078 additions and 539 deletions

View File

@@ -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}`;
};

View File

@@ -0,0 +1 @@
<template><slot id="main" /></template>

View File

@@ -0,0 +1,5 @@
export default defineNuxtRouteMiddleware((to) => {
if (to.query.launcher) {
setPageLayout("empty");
}
});

View File

@@ -1,3 +1,8 @@
<script setup lang="ts">
definePageMeta({
middleware: ["launcher-auth"],
});
</script>
<template>
<NuxtPage class="auth-container universal-card" />
</template>

View File

@@ -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();

View File

@@ -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();