Log error and message when authentication fails

This can help to identify any integration problems when using
providers (e.g. OpenID Connect).
pull/7742/head
Rafal Piotrowski 6 months ago
parent 1b6c67ee77
commit a167361ee0

@ -312,8 +312,14 @@ module.exports = class User extends Model {
session: !strInfo.useForm,
scope: strInfo.scopes ? strInfo.scopes : null
}, async (err, user, info) => {
if (err) { return reject(err) }
if (!user) { return reject(new WIKI.Error.AuthLoginFailed()) }
if (err) {
WIKI.logger.warn(`Error trying to authenticate with strategy ${selStrategy.key}: ${JSON.stringify({ err, info })}`)
return reject(err)
}
if (!user) {
WIKI.logger.info(`Authentication failed with strategy ${selStrategy.key}: ${JSON.stringify(info)}`)
return reject(new WIKI.Error.AuthLoginFailed())
}
try {
const resp = await WIKI.models.users.afterLoginChecks(user, context, {

Loading…
Cancel
Save