1
0
forked from Yara724/api

Fixed Lock for Field expert + user view of files

This commit is contained in:
2026-06-18 13:31:56 +03:30
parent 6df8044c5a
commit d8f7766f10
8 changed files with 328 additions and 234 deletions

View File

@@ -44,3 +44,28 @@ export function buildUserLookupByPhone(
$or: variants.flatMap((v) => [{ username: v }, { mobile: v }]),
};
}
/** True when a blame party person row belongs to the authenticated user. */
export function partyPersonMatchesUser(
person:
| { userId?: unknown; phoneNumber?: string }
| null
| undefined,
user: { sub?: string; username?: string } | null | undefined,
): boolean {
if (!person || !user) return false;
if (
person.userId != null &&
user.sub &&
String(person.userId) === String(user.sub)
) {
return true;
}
if (!person.phoneNumber || !user.username) return false;
const stored =
normalizeIranMobile(person.phoneNumber) ?? person.phoneNumber;
const variants = iranMobileLookupVariants(user.username);
return variants.some(
(v) => v === stored || v === person.phoneNumber,
);
}