const jwt = require('jsonwebtoken'); exports.handleCallback = async (req, res) => { try { if (!req.user.isAccountSetupComplete) { res.redirect('/register'); } else { const sessionExpiration = parseInt(process.env.SESSION_EXPIRATION, 10); const token = jwt.sign( { userId: req.user.id }, process.env.JWT_SECRET, { expiresIn: sessionExpiration } ); // JWTトークンをクッキーに保存 res.cookie('jwt', token, { httpOnly: true, maxAge: sessionExpiration * 1000 }); // Dashboardへリダイレクト res.redirect('/dashboard'); } } catch (err) { console.error(err); res.status(500).send('Internal Server Error'); } }; exports.logout = (req, res) => { req.logout(() => { res.redirect('/'); }); };