Merge pull request 'Fix checkout auth: free-success panel + Stripe auto-init for paid plans' (#51) from fix/checkout-auth-reveal into dev
Dev — Build & local smoke test / build-smoke (push) Failing after 2m12s
Dev — Build & local smoke test / build-smoke (push) Failing after 2m12s
Fix checkout auth: free-success panel + Stripe auto-init for paid plans
This commit was merged in pull request #51.
This commit is contained in:
+18
-2
@@ -29,12 +29,19 @@ fn main() -> Void {
|
|||||||
el.style.color = isError ? '#c0392b' : '#2ecc71';
|
el.style.color = isError ? '#c0392b' : '#2ecc71';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _formRevealed = false;
|
||||||
function revealPaymentForm(user) {
|
function revealPaymentForm(user) {
|
||||||
|
if (_formRevealed) return;
|
||||||
|
_formRevealed = true;
|
||||||
if (user && user.id) { window._neuronSupaId = user.id; }
|
if (user && user.id) { window._neuronSupaId = user.id; }
|
||||||
var auth = document.getElementById('auth-section');
|
var auth = document.getElementById('auth-section');
|
||||||
if (auth) auth.style.display = 'none';
|
if (auth) auth.style.display = 'none';
|
||||||
var isFree = (window.NEURON_CFG || {}).plan === 'free';
|
var isFree = (window.NEURON_CFG || {}).plan === 'free';
|
||||||
if (!isFree) {
|
if (isFree) {
|
||||||
|
// Free plan: show the success panel (user is signed in or just signed up)
|
||||||
|
var freeSuccess = document.getElementById('free-success');
|
||||||
|
if (freeSuccess) freeSuccess.style.display = '';
|
||||||
|
} else {
|
||||||
var payment = document.getElementById('payment-section');
|
var payment = document.getElementById('payment-section');
|
||||||
if (payment) payment.style.display = '';
|
if (payment) payment.style.display = '';
|
||||||
}
|
}
|
||||||
@@ -68,7 +75,16 @@ fn main() -> Void {
|
|||||||
function checkExistingSession() {
|
function checkExistingSession() {
|
||||||
initSupabase(function() {
|
initSupabase(function() {
|
||||||
supabaseClient.auth.getUser().then(function(res) {
|
supabaseClient.auth.getUser().then(function(res) {
|
||||||
if (res.data && res.data.user) { revealPaymentForm(res.data.user); }
|
if (res.data && res.data.user) {
|
||||||
|
revealPaymentForm(res.data.user);
|
||||||
|
} else {
|
||||||
|
// No existing session — for paid plans, init Stripe immediately.
|
||||||
|
// Auth is optional on paid plans; the user can link their account later.
|
||||||
|
var isFree = (window.NEURON_CFG || {}).plan === 'free';
|
||||||
|
if (!isFree && typeof window.initStripe === 'function') {
|
||||||
|
window.initStripe('', '');
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user