π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
feat: get and pass accounts token
httpjamesm5b1eb3df9b40
diff --git a/apps/accounts/src/pages/account-handoff.tsx b/apps/accounts/src/pages/account-handoff.tsxindex cbabafd47b..bb8051391a 100644--- a/apps/accounts/src/pages/account-handoff.tsx+++ b/apps/accounts/src/pages/account-handoff.tsx@@ -3,7 +3,7 @@ import EnteSpinner from '@ente/shared/components/EnteSpinner';import { ACCOUNTS_PAGES } from '@ente/shared/constants/pages';import HTTPService from '@ente/shared/network/HTTPService';import { logError } from '@ente/shared/sentry';-import { LS_KEYS, setData } from '@ente/shared/storage/localStorage';+import { LS_KEYS, getData, setData } from '@ente/shared/storage/localStorage';import { useRouter } from 'next/router';import { useEffect } from 'react';@@ -12,14 +12,7 @@ const AccountHandoff = () => {const retrieveAccountData = () => {try {- // get the data from the fragment- const fragment = window.location.hash.substring(1);-- const stringified = window.atob(fragment);-- const deserialized = JSON.parse(stringified);-- setData(LS_KEYS.USER, deserialized);+ extractAccountsToken();router.push(ACCOUNTS_PAGES.PASSKEYS);} catch (e) {@@ -38,6 +31,19 @@ const AccountHandoff = () => {});};+ const extractAccountsToken = () => {+ const urlParams = new URLSearchParams(window.location.search);+ const token = urlParams.get('token');+ if (!token) {+ throw new Error('token not found');+ }++ let user = getData(LS_KEYS.USER) || {};+ user.token = token;++ setData(LS_KEYS.USER, user);+ };+useEffect(() => {getClientPackageName();retrieveAccountData();diff --git a/apps/photos/src/components/Sidebar/UtilitySection.tsx b/apps/photos/src/components/Sidebar/UtilitySection.tsxindex daa7b96f5f..fe3378f8bc 100644--- a/apps/photos/src/components/Sidebar/UtilitySection.tsx+++ b/apps/photos/src/components/Sidebar/UtilitySection.tsx@@ -15,7 +15,6 @@ 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 { logError } from '@ente/shared/sentry';-import { LS_KEYS, getData } from '@ente/shared/storage/localStorage';import { THEME_COLOR } from '@ente/shared/themes/constants';import { EnteMenuItem } from 'components/Menu/EnteMenuItem';import WatchFolder from 'components/WatchFolder';@@ -73,17 +72,12 @@ export default function UtilitySection({ closeSidebar }) {closeSidebar();try {- // serialize the user data to pass it over to accounts- const userData = getData(LS_KEYS.USER);- const serialized = JSON.stringify(userData);- const serializedB64 = window.btoa(serialized);-const accountsToken = await getAccountsToken();window.location.href = `${getAccountsURL()}${ACCOUNTS_PAGES.ACCOUNT_HANDOFF}?package=${CLIENT_PACKAGE_NAMES.get(APPS.PHOTOS- )}&jwtToken=${accountsToken}#${serializedB64}`;+ )}&token=${accountsToken}`;} catch (e) {logError(e, 'failed to redirect to accounts page');}