feat: getAccountsURL()
This commit is contained in:
parent
e80be51af8
commit
ad1fab8edb
4 changed files with 49 additions and 37 deletions
|
@ -13,6 +13,7 @@ import { AppContext } from 'pages/_app';
|
|||
// import mlIDbStorage from 'utils/storage/mlIDbStorage';
|
||||
import { APPS, CLIENT_PACKAGE_NAMES } from '@ente/shared/apps/constants';
|
||||
import ThemeSwitcher from '@ente/shared/components/ThemeSwitcher';
|
||||
import { getAccountsURL } from '@ente/shared/network/api';
|
||||
import { LS_KEYS, getData } from '@ente/shared/storage/localStorage';
|
||||
import { THEME_COLOR } from '@ente/shared/themes/constants';
|
||||
import { EnteMenuItem } from 'components/Menu/EnteMenuItem';
|
||||
|
@ -74,7 +75,7 @@ export default function UtilitySection({ closeSidebar }) {
|
|||
const serialized = JSON.stringify(userData);
|
||||
const serializedB64 = window.btoa(serialized);
|
||||
|
||||
window.location.href = `${process.env.NEXT_PUBLIC_ACCOUNTS_ENDPOINT}${ACCOUNTS_PAGES.ACCOUNT_HANDOFF
|
||||
window.location.href = `${getAccountsURL()}${ACCOUNTS_PAGES.ACCOUNT_HANDOFF
|
||||
}?package=${CLIENT_PACKAGE_NAMES.get(APPS.PHOTOS)}#${serializedB64}`;
|
||||
};
|
||||
|
||||
|
|
|
@ -2,57 +2,57 @@ import { useEffect, useState } from 'react';
|
|||
|
||||
import { t } from 'i18next';
|
||||
|
||||
import {
|
||||
clearData,
|
||||
getData,
|
||||
LS_KEYS,
|
||||
setData,
|
||||
} from '@ente/shared/storage/localStorage';
|
||||
import { PAGES } from '../constants/pages';
|
||||
import {
|
||||
SESSION_KEYS,
|
||||
getKey,
|
||||
removeKey,
|
||||
setKey,
|
||||
} from '@ente/shared/storage/sessionStorage';
|
||||
import {
|
||||
decryptAndStoreToken,
|
||||
generateAndSaveIntermediateKeyAttributes,
|
||||
generateLoginSubKey,
|
||||
saveKeyInSessionStore,
|
||||
} from '@ente/shared/crypto/helpers';
|
||||
import {
|
||||
clearData,
|
||||
getData,
|
||||
LS_KEYS,
|
||||
setData,
|
||||
} from '@ente/shared/storage/localStorage';
|
||||
import {
|
||||
getKey,
|
||||
removeKey,
|
||||
SESSION_KEYS,
|
||||
setKey,
|
||||
} from '@ente/shared/storage/sessionStorage';
|
||||
import { PAGES } from '../constants/pages';
|
||||
import { generateSRPSetupAttributes } from '../services/srp';
|
||||
import { logoutUser } from '../services/user';
|
||||
|
||||
import { configureSRP, loginViaSRP } from '../services/srp';
|
||||
import { getSRPAttributes } from '../api/srp';
|
||||
import { SRPAttributes } from '../types/srp';
|
||||
|
||||
import { VerticallyCentered } from '@ente/shared/components/Container';
|
||||
import EnteSpinner from '@ente/shared/components/EnteSpinner';
|
||||
import FormPaper from '@ente/shared/components/Form/FormPaper';
|
||||
import FormPaperFooter from '@ente/shared/components/Form/FormPaper/Footer';
|
||||
import FormPaperTitle from '@ente/shared/components/Form/FormPaper/Title';
|
||||
import LinkButton from '@ente/shared/components/LinkButton';
|
||||
import VerifyMasterPasswordForm, {
|
||||
VerifyMasterPasswordFormProps,
|
||||
} from '@ente/shared/components/VerifyMasterPasswordForm';
|
||||
import { getAccountsURL } from '@ente/shared/network/api';
|
||||
import {
|
||||
isFirstLogin,
|
||||
setIsFirstLogin,
|
||||
} from '@ente/shared/storage/localStorage/helpers';
|
||||
import { KeyAttributes, User } from '@ente/shared/user/types';
|
||||
import FormPaper from '@ente/shared/components/Form/FormPaper';
|
||||
import FormPaperTitle from '@ente/shared/components/Form/FormPaper/Title';
|
||||
import FormPaperFooter from '@ente/shared/components/Form/FormPaper/Footer';
|
||||
import LinkButton from '@ente/shared/components/LinkButton';
|
||||
import isElectron from 'is-electron';
|
||||
import { VerticallyCentered } from '@ente/shared/components/Container';
|
||||
import EnteSpinner from '@ente/shared/components/EnteSpinner';
|
||||
import VerifyMasterPasswordForm, {
|
||||
VerifyMasterPasswordFormProps,
|
||||
} from '@ente/shared/components/VerifyMasterPasswordForm';
|
||||
import { getSRPAttributes } from '../api/srp';
|
||||
import { configureSRP, loginViaSRP } from '../services/srp';
|
||||
import { SRPAttributes } from '../types/srp';
|
||||
// import { APPS, getAppName } from '@ente/shared/apps';
|
||||
import { addLocalLog } from '@ente/shared/logging';
|
||||
import { APP_HOMES } from '@ente/shared/apps/constants';
|
||||
import { PageProps } from '@ente/shared/apps/types';
|
||||
import ComlinkCryptoWorker from '@ente/shared/crypto';
|
||||
import { B64EncryptionResult } from '@ente/shared/crypto/types';
|
||||
import { CustomError } from '@ente/shared/error';
|
||||
import InMemoryStore, { MS_KEYS } from '@ente/shared/storage/InMemoryStore';
|
||||
import { PageProps } from '@ente/shared/apps/types';
|
||||
import { APP_HOMES } from '@ente/shared/apps/constants';
|
||||
import { logError } from '@ente/shared/sentry';
|
||||
import ElectronAPIs from '@ente/shared/electron';
|
||||
import { CustomError } from '@ente/shared/error';
|
||||
import { addLocalLog } from '@ente/shared/logging';
|
||||
import { logError } from '@ente/shared/sentry';
|
||||
import InMemoryStore, { MS_KEYS } from '@ente/shared/storage/InMemoryStore';
|
||||
|
||||
export default function Credentials({
|
||||
appContext,
|
||||
|
@ -166,7 +166,8 @@ export default function Credentials({
|
|||
isTwoFactorPasskeysEnabled: true,
|
||||
});
|
||||
InMemoryStore.set(MS_KEYS.REDIRECT_URL, PAGES.ROOT);
|
||||
window.location.href = `${process.env.NEXT_PUBLIC_ACCOUNTS_ENDPOINT}/passkeys/flow?passkeySessionID=${passkeySessionID}&redirect=${window.location.origin}/passkeys/finish`;
|
||||
window.location.href = `${getAccountsURL()}/passkeys/flow?passkeySessionID=${passkeySessionID}&redirect=${window.location.origin
|
||||
}/passkeys/finish`;
|
||||
return;
|
||||
} else if (twoFactorSessionID) {
|
||||
const sessionKeyAttributes =
|
||||
|
|
|
@ -14,6 +14,7 @@ import SingleInputForm, {
|
|||
SingleInputFormProps,
|
||||
} from '@ente/shared/components/SingleInputForm';
|
||||
import { ApiError } from '@ente/shared/error';
|
||||
import { getAccountsURL } from '@ente/shared/network/api';
|
||||
import InMemoryStore, { MS_KEYS } from '@ente/shared/storage/InMemoryStore';
|
||||
import { clearFiles } from '@ente/shared/storage/localForage/helpers';
|
||||
import { LS_KEYS, getData, setData } from '@ente/shared/storage/localStorage';
|
||||
|
@ -80,7 +81,8 @@ export default function VerifyPage({ appContext, router, appName }: PageProps) {
|
|||
isTwoFactorPasskeysEnabled: true,
|
||||
});
|
||||
setIsFirstLogin(true);
|
||||
window.location.href = `${process.env.NEXT_PUBLIC_ACCOUNTS_ENDPOINT}/passkeys/flow?passkeySessionID=${passkeySessionID}&redirect=${window.location.origin}/passkeys/finish`;
|
||||
window.location.href = `${getAccountsURL()}/passkeys/flow?passkeySessionID=${passkeySessionID}&redirect=${window.location.origin
|
||||
}/passkeys/finish`;
|
||||
router.push(PAGES.CREDENTIALS);
|
||||
} else if (twoFactorSessionID) {
|
||||
setData(LS_KEYS.USER, {
|
||||
|
|
|
@ -88,6 +88,14 @@ export const getAuthURL = () => {
|
|||
return `https://auth.ente.io`;
|
||||
};
|
||||
|
||||
export const getAccountsURL = () => {
|
||||
const accountsURL = process.env.NEXT_PUBLIC_ENTE_ACCOUNTS_ENDPOINT;
|
||||
if (isDevDeployment() && accountsURL) {
|
||||
return accountsURL;
|
||||
}
|
||||
return `https://accounts.ente.io`;
|
||||
};
|
||||
|
||||
export const getSentryTunnelURL = () => {
|
||||
return `https://sentry-reporter.ente.io`;
|
||||
};
|
||||
|
@ -103,9 +111,9 @@ export const isDevDeployment = () => {
|
|||
if (globalThis?.location) {
|
||||
return (
|
||||
process.env.NEXT_PUBLIC_ENTE_WEB_ENDPOINT ===
|
||||
globalThis.location.origin ||
|
||||
globalThis.location.origin ||
|
||||
process.env.NEXT_PUBLIC_ENTE_ALBUM_ENDPOINT ===
|
||||
globalThis.location.origin ||
|
||||
globalThis.location.origin ||
|
||||
process.env.NEXT_PUBLIC_IS_TEST_APP === 'true' ||
|
||||
process.env.NODE_ENV === 'development'
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue