mirror of
https://github.com/naturalcrit/naturalcrit.git
synced 2025-10-27 07:29:54 +00:00
Remove try/catch from /google/redirect
Another case where no failure is possible, so we can remove the try/catch block and associated error handlng.
This commit is contained in:
parent
9075627b41
commit
201416514f
@ -46,23 +46,18 @@ router.get('/google',
|
||||
// Google authentication redirect route
|
||||
router.get('/google/redirect',
|
||||
passport.authenticate('google', { session: false }),
|
||||
async (req, res, next) => {
|
||||
try {
|
||||
if (!req.user.username) {
|
||||
}
|
||||
res.cookie('nc_session', jwt, {
|
||||
});
|
||||
res.redirect('/success');
|
||||
} catch (err) {
|
||||
console.error('Error during Google redirect:', err);
|
||||
res.status(500).send('Internal Server Error');
|
||||
}
|
||||
(req, res, next) => {
|
||||
if (!req.user.username)
|
||||
return next(); // Stay on the page if we still need local sign-in
|
||||
|
||||
const jwt = generateUserToken(req, res);
|
||||
res.cookie('nc_session', jwt, {
|
||||
maxAge : 1000 * 60 * 60 * 24 * 365, // 1 year
|
||||
path : '/',
|
||||
sameSite : 'lax',
|
||||
domain : '.naturalcrit.com', // Set domain for the cookie.
|
||||
});
|
||||
res.redirect('/success');
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user