feat: improved saml error messages

This commit is contained in:
=
2025-04-18 22:24:01 +05:30
parent 233740e029
commit f5d7809515
2 changed files with 13 additions and 7 deletions
+1 -1
View File
@@ -136,7 +136,7 @@ declare module "fastify" {
rateLimits: RateLimitConfiguration; rateLimits: RateLimitConfiguration;
// passport data // passport data
passportUser: { passportUser: {
isUserCompleted: string; isUserCompleted: boolean;
providerAuthToken: string; providerAuthToken: string;
}; };
kmipUser: { kmipUser: {
+12 -6
View File
@@ -223,12 +223,18 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
samlConfigId: z.string().trim() samlConfigId: z.string().trim()
}) })
}, },
preValidation: passport.authenticate("saml", { preValidation: passport.authenticate(
session: false, "saml",
failureFlash: true, {
failureRedirect: "/login/provider/error" session: false
// this is due to zod type difference },
}) as any, async (req, res, err, user) => {
if (err) {
throw new BadRequestError({ message: `Saml authentication failed. ${err?.message}`, error: err });
}
req.passportUser = user as { isUserCompleted: boolean; providerAuthToken: string };
}
) as any, // this is due to zod type difference
handler: (req, res) => { handler: (req, res) => {
if (req.passportUser.isUserCompleted) { if (req.passportUser.isUserCompleted) {
return res.redirect( return res.redirect(