Protecting Content
Reading access
Reacting to changes
When to use what
Scenario
Method
What happens
Example
tiun.on('userChange', (data) => {
const { event, isAuthenticated, user } = data;
if (!isAuthenticated || !user) {
showPublicExperience();
return;
}
const hasPremium = user.productAccess?.some(
(p) => p.productId === 'YOUR_PRODUCT_ID'
);
if (hasPremium) {
showPremiumContent();
} else {
showUpgradePrompt();
}
});Last updated
Was this helpful?