Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1universalStack: any
authsessionvalidationcorrectness
Guard against a falsy session before relying on it
Check that an auth/session cookie exists (and decide how to handle anonymous users) before using it to gate behavior; throw or short-circuit when it's falsy.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const voted = await checkVote(blaizeSession); // blaizeSession may be falsy |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (!blaizeSession) throw new Error('Missing session'); |
| 2 | const voted = await checkVote(blaizeSession); |
Explanation (EN)
Objašnjenje (HR)