Skip to content

armgit / ente

Public Imported from GitHub
0

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

Preserve password change detection without cached metadata

Neeraj Gupta72acaa4adecc
diff --git a/web/apps/photos/tests/password-change.test.ts b/web/apps/photos/tests/password-change.test.ts
index e9dbd9a430..7090a8f2b9 100644
--- a/web/apps/photos/tests/password-change.test.ts
+++ b/web/apps/photos/tests/password-change.test.ts
@@ -129,13 +129,13 @@ test.each([true, false])(
);
test.each([
- [true, true, "validButPasswordChanged"],
- [false, true, "validButPasswordChanged"],
- [true, false, "validButPasswordChanged"],
- [false, false, "valid"],
+ [true, true],
+ [false, true],
+ [true, false],
+ [false, false],
])(
- "session check with SRP cache %s and original keys %s returns %s",
- async (hasSRP, hasOriginal, status) => {
+ "password change elsewhere is detected with SRP cache %s and original keys %s",
+ async (hasSRP, hasOriginal) => {
if (!hasSRP) localStorage.removeItem("srpAttributes");
if (!hasOriginal) localStorage.removeItem("originalKeyAttributes");
const result = {
@@ -148,15 +148,9 @@ test.each([
};
rustCheckSessionValidity.mockResolvedValue(result);
- await expect(checkSessionValidity()).resolves.toEqual(
- status === "valid" ? { status } : result,
- );
+ await expect(checkSessionValidity()).resolves.toEqual(result);
expect(savedSRPAttributes()).toEqual(
- status === "valid"
- ? result.updatedSRPAttributes
- : hasSRP
- ? originalSRPAttributes
- : undefined,
+ hasSRP ? originalSRPAttributes : undefined,
);
},
);
diff --git a/web/packages/accounts/services/session.ts b/web/packages/accounts/services/session.ts
index d3d2099d4a..9d10883d9d 100644
--- a/web/packages/accounts/services/session.ts
+++ b/web/packages/accounts/services/session.ts
@@ -51,9 +51,7 @@ export const checkSessionValidity = async () => {
);
if (
result.status === "validButPasswordChanged" &&
- (result.updatedSRPAttributes.kekSalt ===
- originalKeyAttributes?.kekSalt ||
- (!localSRPAttributes && !originalKeyAttributes))
+ result.updatedSRPAttributes.kekSalt === originalKeyAttributes?.kekSalt
) {
saveSRPAttributes(result.updatedSRPAttributes);
return { status: "valid" as const };