pl-fe: Remove obsolete workaround for Mitra

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-10-09 19:52:31 +02:00
parent cffc9d7332
commit e5728edb4e
2 changed files with 9 additions and 30 deletions

View file

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

View file

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