fix: Skip OAuth if already logged in, go straight to checkout

If user has existing session from Trinity Console login,
/stripe/auth now redirects directly to /stripe/checkout
instead of re-triggering Discord OAuth.

Chronicler #75
This commit is contained in:
Claude
2026-04-10 15:06:34 +00:00
parent 2740dc5fd3
commit 0acea3b95f

View File

@@ -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);