Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Check an identity provider's secondary fields, not just the primary identifier
When resolving a user's email from an external IdP, fall back to the attributes bag — some users have a different primary identifier (e.g. phone) with email only present as a secondary attribute.
Bad example
| 1 | const email = blaizeUser?.identifiers?.email_address ?? null; |
Explanation (EN)
Users who registered with a phone number as their primary identifier have no `identifiers.email_address`, even though their email is stored elsewhere on the profile — this silently drops their email.
Objašnjenje (HR)
Korisnici koji su se registrirali s brojem telefona kao primarnim identifikatorom nemaju `identifiers.email_address`, iako je njihov email pohranjen negdje drugdje na profilu — ovo tiho izgubi njihov email.
Good example
| 1 | const email = blaizeUser?.identifiers?.email_address ?? blaizeUser?.attributes?.email ?? null; |
Explanation (EN)
Fall back to the attributes bag when the primary identifier field is absent, so phone-primary users are still resolved correctly.
Objašnjenje (HR)
Vrati se na skup atributa kada primarno polje identifikatora nedostaje, tako da se korisnici s telefonom kao primarnim identifikatorom i dalje ispravno razrijese.
Notes (EN)
Verify with the IdP's actual data model which fields can hold each value across different registration methods before assuming one canonical field.
Bilješke (HR)
Provjeri sa stvarnim modelom podataka IdP-a koja polja mogu sadrzavati koju vrijednost kroz razlicite metode registracije prije nego pretpostavis jedno kanonsko polje.