fix(accounts): separate Debrid-Link username and email

Persist the username and email returned by the Debrid-Link account endpoint as distinct identity fields and project them into their matching account-table columns. Migrate cached legacy statuses that stored a username in the email field, preserve both fields through renderer validation and sanitization, and cover API responses with and without an email address.
This commit is contained in:
Sucukdeluxe
2026-08-15 02:11:59 +02:00
parent 90fc77f203
commit d91e2a4ab9
10 changed files with 99 additions and 42 deletions
+29 -1
View File
@@ -673,7 +673,8 @@ describe("settings storage", () => {
valid: true,
isPremium: true,
premiumUntilMs: checkedAt + 1000,
email: "web-user",
username: "web-user",
email: "w***r@example.test",
message: "Premium aktiv",
checkedAt
}
@@ -684,9 +685,36 @@ describe("settings storage", () => {
accountId: "svc-realdebrid",
provider: "realdebrid",
valid: true,
username: "web-user",
email: "w***r@example.test",
checkedAt
});
});
it("migrates a legacy Debrid-Link username out of the email field", () => {
const [key] = parseDebridLinkApiKeys("dl-key-one");
const normalized = normalizeSettings({
...defaultSettings(),
debridLinkApiKeys: "dl-key-one",
debridAccountStatuses: {
[key.id]: {
accountId: key.id,
provider: "debridlink",
label: "Key 1",
maskedLogin: key.masked,
valid: true,
isPremium: false,
premiumUntilMs: 0,
email: "xsucukde5",
message: "Kein Premium (Free)",
checkedAt: Date.now()
}
}
});
expect(normalized.debridAccountStatuses[key.id].username).toBe("xsucukde5");
expect(normalized.debridAccountStatuses[key.id].email).toBeUndefined();
});
it("defaults AllDebrid web login to disabled and normalizes the flag", () => {
expect(defaultSettings().allDebridUseWebLogin).toBe(false);