Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Prune

Manav Rathi2213b7c39f7d
diff --git a/web/packages/accounts/api/user.ts b/web/packages/accounts/api/user.ts
index d14402ebe1..55d48b4d16 100644
--- a/web/packages/accounts/api/user.ts
+++ b/web/packages/accounts/api/user.ts
@@ -1,3 +1,4 @@
+import type { AppName } from "@/next/types/app";
import type {
RecoveryKey,
TwoFactorRecoveryResponse,
@@ -5,7 +6,6 @@ import type {
TwoFactorVerificationResponse,
UserVerificationResponse,
} from "@ente/accounts/types/user";
-import { APPS, OTT_CLIENTS } from "@ente/shared/apps/constants";
import type { B64EncryptionResult } from "@ente/shared/crypto/types";
import { ApiError, CustomError } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";
@@ -17,10 +17,10 @@ import { TwoFactorType } from "../constants/twofactor";
const ENDPOINT = getEndpoint();
-export const sendOtt = (appName: APPS, email: string) => {
+export const sendOtt = (appName: AppName, email: string) => {
return HTTPService.post(`${ENDPOINT}/users/ott`, {
email,
- client: OTT_CLIENTS.get(appName),
+ client: appName == "auth" ? "totp" : "web",
});
};
diff --git a/web/packages/accounts/components/Login.tsx b/web/packages/accounts/components/Login.tsx
index 297aa28ecd..50cebd56ee 100644
--- a/web/packages/accounts/components/Login.tsx
+++ b/web/packages/accounts/components/Login.tsx
@@ -1,6 +1,5 @@
import log from "@/next/log";
import type { AppName } from "@/next/types/app";
-import { appNameToAppNameOld } from "@ente/shared/apps/constants";
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";
@@ -20,9 +19,7 @@ interface LoginProps {
appName: AppName;
}
-export function Login(props: LoginProps) {
- const appNameOld = appNameToAppNameOld(props.appName);
-
+export function Login({ appName, signUp }: LoginProps) {
const router = useRouter();
const loginUser: SingleInputFormProps["callback"] = async (
@@ -34,7 +31,7 @@ export function Login(props: LoginProps) {
const srpAttributes = await getSRPAttributes(email);
log.debug(() => ` srpAttributes: ${JSON.stringify(srpAttributes)}`);
if (!srpAttributes || srpAttributes.isEmailMFAEnabled) {
- await sendOtt(appNameOld, email);
+ await sendOtt(appName, email);
router.push(PAGES.VERIFY);
} else {
setData(LS_KEYS.SRP_ATTRIBUTES, srpAttributes);
@@ -66,9 +63,7 @@ export function Login(props: LoginProps) {
/>
<FormPaperFooter>
- <LinkButton onClick={props.signUp}>
- {t("NO_ACCOUNT")}
- </LinkButton>
+ <LinkButton onClick={signUp}>{t("NO_ACCOUNT")}</LinkButton>
</FormPaperFooter>
</>
);
diff --git a/web/packages/accounts/components/SignUp.tsx b/web/packages/accounts/components/SignUp.tsx
index 044eaa966f..9e0086075b 100644
--- a/web/packages/accounts/components/SignUp.tsx
+++ b/web/packages/accounts/components/SignUp.tsx
@@ -6,7 +6,6 @@ import { PAGES } from "@ente/accounts/constants/pages";
import { isWeakPassword } from "@ente/accounts/utils";
import { generateKeyAndSRPAttributes } from "@ente/accounts/utils/srp";
import { LS_KEYS } from "@ente/shared//storage/localStorage";
-import { appNameToAppNameOld } from "@ente/shared/apps/constants";
import { VerticallyCentered } from "@ente/shared/components/Container";
import FormPaperFooter from "@ente/shared/components/Form/FormPaper/Footer";
import FormPaperTitle from "@ente/shared/components/Form/FormPaper/Title";
@@ -57,8 +56,6 @@ interface SignUpProps {
}
export function SignUp({ router, appName, login }: SignUpProps) {
- const appNameOld = appNameToAppNameOld(appName);
-
const [acceptTerms, setAcceptTerms] = useState(false);
const [loading, setLoading] = useState(false);
const [showPassword, setShowPassword] = useState(false);
@@ -86,7 +83,7 @@ export function SignUp({ router, appName, login }: SignUpProps) {
try {
setData(LS_KEYS.USER, { email });
setLocalReferralSource(referral);
- await sendOtt(appNameOld, email);
+ await sendOtt(appName, email);
} catch (e) {
const message = e instanceof Error ? e.message : "";
setFieldError("confirm", `${t("UNKNOWN_ERROR")} ${message}`);
diff --git a/web/packages/accounts/pages/recover.tsx b/web/packages/accounts/pages/recover.tsx
index 1e8b99895b..afc528136c 100644
--- a/web/packages/accounts/pages/recover.tsx
+++ b/web/packages/accounts/pages/recover.tsx
@@ -2,7 +2,7 @@ import log from "@/next/log";
import { ensure } from "@/utils/ensure";
import { sendOtt } from "@ente/accounts/api/user";
import { PAGES } from "@ente/accounts/constants/pages";
-import { APP_HOMES, appNameToAppNameOld } from "@ente/shared/apps/constants";
+import { APP_HOMES } from "@ente/shared/apps/constants";
import { VerticallyCentered } from "@ente/shared/components/Container";
import FormPaper from "@ente/shared/components/Form/FormPaper";
import FormPaperFooter from "@ente/shared/components/Form/FormPaper/Footer";
@@ -32,8 +32,6 @@ bip39.setDefaultWordlist("english");
const Page: React.FC<PageProps> = ({ appContext }) => {
const { appName } = appContext;
- const appNameOld = appNameToAppNameOld(appName);
-
const [keyAttributes, setKeyAttributes] = useState<
KeyAttributes | undefined
>();
@@ -49,7 +47,7 @@ const Page: React.FC<PageProps> = ({ appContext }) => {
return;
}
if (!user?.encryptedToken && !user?.token) {
- sendOtt(appNameOld, user.email);
+ sendOtt(appName, user.email);
InMemoryStore.set(MS_KEYS.REDIRECT_URL, PAGES.RECOVER);
router.push(PAGES.VERIFY);
return;
diff --git a/web/packages/accounts/pages/verify.tsx b/web/packages/accounts/pages/verify.tsx
index 01e6e5884d..d5c004d9ae 100644
--- a/web/packages/accounts/pages/verify.tsx
+++ b/web/packages/accounts/pages/verify.tsx
@@ -36,8 +36,6 @@ import type { SRPSetupAttributes } from "../types/srp";
const Page: React.FC<PageProps> = ({ appContext }) => {
const { appName, logout } = appContext;
- const appNameOld = appNameToAppNameOld(appName);
-
const [email, setEmail] = useState("");
const [resend, setResend] = useState(0);
@@ -151,7 +149,7 @@ const Page: React.FC<PageProps> = ({ appContext }) => {
const resendEmail = async () => {
setResend(1);
- await sendOtt(appNameOld, email);
+ await sendOtt(appName, email);
setResend(2);
setTimeout(() => setResend(0), 3000);
};
diff --git a/web/packages/shared/apps/constants.ts b/web/packages/shared/apps/constants.ts
index 953b6c486c..cd780312ef 100644
--- a/web/packages/shared/apps/constants.ts
+++ b/web/packages/shared/apps/constants.ts
@@ -31,8 +31,3 @@ export const APP_HOMES = new Map([
[APPS.AUTH, AUTH_PAGES.AUTH],
[APPS.ACCOUNTS, ACCOUNTS_PAGES.PASSKEYS],
]);
-
-export const OTT_CLIENTS = new Map([
- [APPS.PHOTOS, "web"],
- [APPS.AUTH, "totp"],
-]);