We’ll probably need the logs from that event. Could you capture them and send them over?
This usually happens if passport didn’t receive (or could not receive) an actual user back, and it might be a misconfiguration on your keycloak instance’s side.
* (passport.authenticate() by default doesn't, so don't use it)
* @param {import('passport').Strategy | string} strategy
* @param {import('passport').AuthenticateOptions | undefined} [options]
* @returns {import('express').Handler}
*/
function passportAuthenticate(strategy, options = undefined) {
return (req, res, next) =>
passport.authenticate(strategy, options, (err, user, info) => {
if (err && !(err instanceof UserInputError)) logger.error(err)
if (!user) {
const errMsg = info?.message || 'Failed to authenticate, contact server admins'
let errPath = `/error?message=${errMsg}`
if (err instanceof UnverifiedEmailSSOLoginError) {
const email = err.info()?.email || ''
errPath = `/error-email-verify?email=${email}`
}
return useNewFrontend()
? res.redirect(new URL(errPath, getFrontendOrigin()).toString())
: res.redirect(errPath)