From 88ac29ea1411cc829ca95473b4ca46cbc90e5aa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez?= Date: Fri, 13 Jan 2023 19:08:15 +0100 Subject: [PATCH] fix: allow multiple accounts on same server (#1092) --- components/user/UserSignIn.vue | 3 +++ server/api/[server]/login.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/user/UserSignIn.vue b/components/user/UserSignIn.vue index f64cdc7f..73adec4f 100644 --- a/components/user/UserSignIn.vue +++ b/components/user/UserSignIn.vue @@ -11,6 +11,8 @@ let knownServers = $ref([]) let autocompleteIndex = $ref(0) let autocompleteShow = $ref(false) +const users = useUsers() + async function oauth() { if (busy) return @@ -28,6 +30,7 @@ async function oauth() { location.href = await (globalThis.$fetch as any)(`/api/${server || publicServer.value}/login`, { method: 'POST', body: { + force_login: users.value.some(u => u.server === server), origin: location.origin, }, }) diff --git a/server/api/[server]/login.ts b/server/api/[server]/login.ts index f01945eb..f80b2923 100644 --- a/server/api/[server]/login.ts +++ b/server/api/[server]/login.ts @@ -4,7 +4,7 @@ import { getApp, getRedirectURI } from '~/server/shared' export default defineEventHandler(async (event) => { let { server } = getRouterParams(event) - const { origin } = await readBody(event) + const { origin, force_login } = await readBody(event) server = server.toLocaleLowerCase().trim() const app = await getApp(origin, server) @@ -17,6 +17,7 @@ export default defineEventHandler(async (event) => { const query = stringifyQuery({ client_id: app.client_id, + force_login: force_login === true ? 'true' : 'false', scope: 'read write follow push', redirect_uri: getRedirectURI(origin, server), response_type: 'code',