fix(handlers): disabling 2fa methods may result in a bad ux ()

This fixes an issue where disabled 2FA methods may appear to users as available.

Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
This commit is contained in:
James Elliott 2024-05-29 23:09:21 +10:00 committed by GitHub
parent 2eaef3ca80
commit 010b7fa5e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -57,6 +57,18 @@ func UserInfoPOST(ctx *middlewares.AutheliaCtx) {
}
}
if ctx.Configuration.TOTP.Disable {
userInfo.HasTOTP = false
}
if ctx.Configuration.WebAuthn.Disable {
userInfo.HasWebAuthn = false
}
if ctx.Configuration.DuoAPI.Disable {
userInfo.HasDuo = false
}
userInfo.DisplayName = userSession.DisplayName
err = ctx.SetJSONBody(userInfo)

View File

@ -189,7 +189,7 @@ func TestUserInfoEndpoint_SetDefaultMethod(t *testing.T) {
Method: "totp",
HasTOTP: false,
HasWebAuthn: false,
HasDuo: true,
HasDuo: false,
},
config: &schema.Configuration{DuoAPI: schema.DuoAPI{Disable: true}},
loadErr: nil,
@ -205,7 +205,7 @@ func TestUserInfoEndpoint_SetDefaultMethod(t *testing.T) {
},
api: &model.UserInfo{
Method: "webauthn",
HasTOTP: true,
HasTOTP: false,
HasWebAuthn: true,
HasDuo: true,
},