fix: expose DBN_USER_TIER so plus/pro SSO users can use doc picker
isPaidUser() was checking DBN_FREE_TIER_BALANCE === undefined, which is only true for CaveauAI sessions. SSO users (even plus/pro) always have DBN_FREE_TIER_BALANCE set, so the picker was showing the upgrade modal for everyone in the SSO flow. Now reads DBN_USER_TIER explicitly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,8 +13,12 @@
|
|||||||
// DBN_FREE_TIER_BALANCE is set only for SSO (free) users.
|
// DBN_FREE_TIER_BALANCE is set only for SSO (free) users.
|
||||||
// Paid CaveauAI sessions have it undefined.
|
// Paid CaveauAI sessions have it undefined.
|
||||||
function isPaidUser() {
|
function isPaidUser() {
|
||||||
return window.DBN_TOOLS_AUTHENTICATED === true
|
if (window.DBN_TOOLS_AUTHENTICATED !== true) return false;
|
||||||
&& typeof window.DBN_FREE_TIER_BALANCE === 'undefined';
|
// CaveauAI sessions never have DBN_FREE_TIER_BALANCE set
|
||||||
|
if (typeof window.DBN_FREE_TIER_BALANCE === 'undefined') return true;
|
||||||
|
// SSO sessions: check the explicit tier variable
|
||||||
|
var t = window.DBN_USER_TIER;
|
||||||
|
return t === 'plus' || t === 'pro';
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Upgrade modal ─────────────────────────────────────────────────────────
|
// ── Upgrade modal ─────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ window.DBN_TOOLS_AUTHENTICATED = <?= $layoutIsGuest ? 'false' : 'true' ?>;
|
|||||||
window.DBN_TOOLS_LANG = <?= json_encode($uiLang, JSON_UNESCAPED_UNICODE) ?>;
|
window.DBN_TOOLS_LANG = <?= json_encode($uiLang, JSON_UNESCAPED_UNICODE) ?>;
|
||||||
<?php if ($layoutFreeTierBalance >= 0): ?>
|
<?php if ($layoutFreeTierBalance >= 0): ?>
|
||||||
window.DBN_FREE_TIER_BALANCE = <?= $layoutFreeTierBalance ?>;
|
window.DBN_FREE_TIER_BALANCE = <?= $layoutFreeTierBalance ?>;
|
||||||
|
window.DBN_USER_TIER = <?= json_encode(FreeTier::tier((int)$_SESSION['dbn_tools_sso_uid'])) ?>;
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</script>
|
</script>
|
||||||
<?php if (date('m-d') === '05-17'): ?>
|
<?php if (date('m-d') === '05-17'): ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user