diff --git a/services/arbiter-3.0/src/routes/stripe.js b/services/arbiter-3.0/src/routes/stripe.js index 45f3118..df34fba 100644 --- a/services/arbiter-3.0/src/routes/stripe.js +++ b/services/arbiter-3.0/src/routes/stripe.js @@ -30,7 +30,8 @@ router.options('/create-checkout-session', cors(corsOptions)); /** * STRIPE AUTH - Entry point from website * GET /stripe/auth?tier=X - * Stores tier in session, redirects to Discord OAuth + * If already logged in, goes straight to checkout + * If not, stores tier in session and redirects to Discord OAuth */ router.get('/auth', (req, res) => { const tierLevel = req.query.tier; @@ -39,6 +40,11 @@ router.get('/auth', (req, res) => { return res.status(400).send('Invalid tier level. Please return to the subscribe page and try again.'); } + // If user is already authenticated, skip OAuth and go straight to checkout + if (req.user && req.user.id) { + return res.redirect(`/stripe/checkout?tier=${tierLevel}`); + } + // Store tier in session for after OAuth callback req.session.pendingCheckoutTier = parseInt(tierLevel);