mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 17:03:15 +00:00
1ff8a814ae
Preserve the provider mailbox on new accounts. For existing accounts, use the stored issuer and subject or check mailbox identity before linking. Keep the candidate lookup and identity update inside the same transaction.
11 lines
459 B
TypeScript
11 lines
459 B
TypeScript
export function sameMailbox(stored: string, claimed: string): boolean {
|
|
const storedAt = stored.lastIndexOf('@');
|
|
const claimedAt = claimed.lastIndexOf('@');
|
|
if (storedAt < 1 || claimedAt < 1 || storedAt === stored.length - 1 || claimedAt === claimed.length - 1) return false;
|
|
|
|
return (
|
|
stored.slice(0, storedAt) === claimed.slice(0, claimedAt) &&
|
|
stored.slice(storedAt + 1).toLowerCase() === claimed.slice(claimedAt + 1).toLowerCase()
|
|
);
|
|
}
|