Fix checkout auth (dev → stage) #52
+18
-2
@@ -29,12 +29,19 @@ fn main() -> Void {
|
||||
el.style.color = isError ? '#c0392b' : '#2ecc71';
|
||||
}
|
||||
|
||||
var _formRevealed = false;
|
||||
function revealPaymentForm(user) {
|
||||
if (_formRevealed) return;
|
||||
_formRevealed = true;
|
||||
if (user && user.id) { window._neuronSupaId = user.id; }
|
||||
var auth = document.getElementById('auth-section');
|
||||
if (auth) auth.style.display = 'none';
|
||||
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');
|
||||
if (payment) payment.style.display = '';
|
||||
}
|
||||
@@ -68,7 +75,16 @@ fn main() -> Void {
|
||||
function checkExistingSession() {
|
||||
initSupabase(function() {
|
||||
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