From e5728edb4ebbebcec8e6a599ec440e522ab59715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 9 Oct 2024 19:52:31 +0200 Subject: [PATCH] pl-fe: Remove obsolete workaround for Mitra MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- packages/pl-fe/src/actions/external-auth.ts | 23 ++++++++------------- packages/pl-fe/src/utils/quirks.ts | 16 -------------- 2 files changed, 9 insertions(+), 30 deletions(-) delete mode 100644 packages/pl-fe/src/utils/quirks.ts diff --git a/packages/pl-fe/src/actions/external-auth.ts b/packages/pl-fe/src/actions/external-auth.ts index d2b6bbf20..db8626377 100644 --- a/packages/pl-fe/src/actions/external-auth.ts +++ b/packages/pl-fe/src/actions/external-auth.ts @@ -13,7 +13,6 @@ import { authLoggedIn, verifyCredentials, switchAccount } from 'pl-fe/actions/au import { obtainOAuthToken } from 'pl-fe/actions/oauth'; import { parseBaseURL } from 'pl-fe/utils/auth'; import sourceCode from 'pl-fe/utils/code'; -import { getQuirks } from 'pl-fe/utils/quirks'; import { getInstanceScopes } from 'pl-fe/utils/scopes'; import type { AppDispatch } from 'pl-fe/store'; @@ -31,21 +30,17 @@ const fetchExternalInstance = (baseURL: string) => } }); -const createExternalApp = (instance: Instance, baseURL?: string) => - (dispatch: AppDispatch) => { - // Mitra: skip creating the auth app - if (getQuirks(instance).noApps) return new Promise(f => f({})); - - const params = { - client_name: `${sourceCode.displayName} (${new URL(window.origin).host})`, - redirect_uris: `${window.location.origin}/login/external`, - website: sourceCode.homepage, - scopes: getInstanceScopes(instance), - }; - - return dispatch(createApp(params, baseURL)); +const createExternalApp = (instance: Instance, baseURL?: string) => { + const params = { + client_name: `${sourceCode.displayName} (${new URL(window.origin).host})`, + redirect_uris: `${window.location.origin}/login/external`, + website: sourceCode.homepage, + scopes: getInstanceScopes(instance), }; + return createApp(params, baseURL); +}; + const externalAuthorize = (instance: Instance, baseURL: string) => (dispatch: AppDispatch) => { const scopes = getInstanceScopes(instance); diff --git a/packages/pl-fe/src/utils/quirks.ts b/packages/pl-fe/src/utils/quirks.ts deleted file mode 100644 index ed6f3fdea..000000000 --- a/packages/pl-fe/src/utils/quirks.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { getFeatures, MITRA, type Instance } from 'pl-api'; -import { createSelector } from 'reselect'; - -/** For solving bugs between API implementations. */ -const getQuirks = createSelector([ - (instance: Instance) => getFeatures(instance).version, -], (v) => ({ - /** - * Apps are not supported by the API, and should not be created during login or registration. - * @see POST /api/v1/apps - * @see POST /oauth/token - */ - noApps: v.software === MITRA, -})); - -export { getQuirks };