Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

handled error cases for external auth login

Sheen Capadngan6ca3b8ba6111
diff --git a/backend/src/routes/v1/oauth.ts b/backend/src/routes/v1/oauth.ts
index fd2a5c803c..d817e64673 100644
--- a/backend/src/routes/v1/oauth.ts
+++ b/backend/src/routes/v1/oauth.ts
@@ -5,18 +5,18 @@ import { oauthController } from '../../controllers/v1';
import { authLimiter } from '../../helpers/rateLimiter';
router.get(
- '/redirect/google',
- authLimiter,
- passport.authenticate('google', {
- scope: ['profile', 'email'],
- session: false,
- }),
- )
-
+ '/redirect/google',
+ authLimiter,
+ passport.authenticate('google', {
+ scope: ['profile', 'email'],
+ session: false,
+ }),
+)
+
router.get(
- '/callback/google',
- passport.authenticate('google', { failureRedirect: '/error', session: false }),
- oauthController.handleAuthProviderCallback,
+ '/callback/google',
+ passport.authenticate('google', { failureRedirect: '/login/provider/error', session: false }),
+ oauthController.handleAuthProviderCallback,
)
export default router;
diff --git a/backend/src/utils/auth.ts b/backend/src/utils/auth.ts
index 511c20d650..bde062b56a 100644
--- a/backend/src/utils/auth.ts
+++ b/backend/src/utils/auth.ts
@@ -106,7 +106,7 @@ const initializePassport = async () => {
req.providerAuthToken = providerAuthToken;
cb(null, profile);
} catch (err) {
- cb(err);
+ cb(null, false);
}
}));
}
diff --git a/frontend/src/const.ts b/frontend/src/const.ts
index 8d0044b2a0..a16ca42321 100644
--- a/frontend/src/const.ts
+++ b/frontend/src/const.ts
@@ -17,7 +17,8 @@ export const publicPaths = [
`/subprocessors`,
`/verify-email`,
`/password-reset`,
- `/login/provider/success`
+ `/login/provider/success`,
+ `/login/provider/error`
];
export const languageMap = {
diff --git a/frontend/src/pages/login/provider/error.tsx b/frontend/src/pages/login/provider/error.tsx
new file mode 100644
index 0000000000..3f9a0fe0cf
--- /dev/null
+++ b/frontend/src/pages/login/provider/error.tsx
@@ -0,0 +1,7 @@
+export default function LoginProviderError() {
+ return (
+ <div className="bg-gradient-to-tr from-bunker-500 to-bunker-800 h-screen flex flex-col justify-center pb-28 px-6 items-center">
+ <span className="text-white text-xl" >Oops! An error has occured.</span>
+ </div>
+ )
+}