mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 08:12:00 +02:00
📜 refactor: Log Error Messages when OAuth Fails (#5337)
This commit is contained in:
parent
e6670cd411
commit
d048a10b2e
1 changed files with 11 additions and 5 deletions
|
@ -28,6 +28,12 @@ const oauthHandler = async (req, res) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
router.get('/error', (req, res) => {
|
||||||
|
// A single error message is pushed by passport when authentication fails.
|
||||||
|
logger.error('Error in OAuth authentication:', { message: req.session.messages.pop() });
|
||||||
|
res.redirect(`${domains.client}/login`);
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Google Routes
|
* Google Routes
|
||||||
*/
|
*/
|
||||||
|
@ -42,7 +48,7 @@ router.get(
|
||||||
router.get(
|
router.get(
|
||||||
'/google/callback',
|
'/google/callback',
|
||||||
passport.authenticate('google', {
|
passport.authenticate('google', {
|
||||||
failureRedirect: `${domains.client}/login`,
|
failureRedirect: `${domains.client}/oauth/error`,
|
||||||
failureMessage: true,
|
failureMessage: true,
|
||||||
session: false,
|
session: false,
|
||||||
scope: ['openid', 'profile', 'email'],
|
scope: ['openid', 'profile', 'email'],
|
||||||
|
@ -62,7 +68,7 @@ router.get(
|
||||||
router.get(
|
router.get(
|
||||||
'/facebook/callback',
|
'/facebook/callback',
|
||||||
passport.authenticate('facebook', {
|
passport.authenticate('facebook', {
|
||||||
failureRedirect: `${domains.client}/login`,
|
failureRedirect: `${domains.client}/oauth/error`,
|
||||||
failureMessage: true,
|
failureMessage: true,
|
||||||
session: false,
|
session: false,
|
||||||
scope: ['public_profile'],
|
scope: ['public_profile'],
|
||||||
|
@ -81,7 +87,7 @@ router.get(
|
||||||
router.get(
|
router.get(
|
||||||
'/openid/callback',
|
'/openid/callback',
|
||||||
passport.authenticate('openid', {
|
passport.authenticate('openid', {
|
||||||
failureRedirect: `${domains.client}/login`,
|
failureRedirect: `${domains.client}/oauth/error`,
|
||||||
failureMessage: true,
|
failureMessage: true,
|
||||||
session: false,
|
session: false,
|
||||||
}),
|
}),
|
||||||
|
@ -99,7 +105,7 @@ router.get(
|
||||||
router.get(
|
router.get(
|
||||||
'/github/callback',
|
'/github/callback',
|
||||||
passport.authenticate('github', {
|
passport.authenticate('github', {
|
||||||
failureRedirect: `${domains.client}/login`,
|
failureRedirect: `${domains.client}/oauth/error`,
|
||||||
failureMessage: true,
|
failureMessage: true,
|
||||||
session: false,
|
session: false,
|
||||||
scope: ['user:email', 'read:user'],
|
scope: ['user:email', 'read:user'],
|
||||||
|
@ -117,7 +123,7 @@ router.get(
|
||||||
router.get(
|
router.get(
|
||||||
'/discord/callback',
|
'/discord/callback',
|
||||||
passport.authenticate('discord', {
|
passport.authenticate('discord', {
|
||||||
failureRedirect: `${domains.client}/login`,
|
failureRedirect: `${domains.client}/oauth/error`,
|
||||||
failureMessage: true,
|
failureMessage: true,
|
||||||
session: false,
|
session: false,
|
||||||
scope: ['identify', 'email'],
|
scope: ['identify', 'email'],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue