Browse Source

Fix misleading error code when receiving invalid WebAuthn credentials (#23568)

closed-social-glitch-2
Claire 1 year ago
committed by GitHub
parent
commit
a232a1feb8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions
  1. +1
    -1
      app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb
  2. +2
    -2
      spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb

+ 1
- 1
app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb View File

@ -52,7 +52,7 @@ module Settings
end end
else else
flash[:error] = I18n.t('webauthn_credentials.create.error') flash[:error] = I18n.t('webauthn_credentials.create.error')
status = :internal_server_error
status = :unprocessable_entity
end end
else else
flash[:error] = t('webauthn_credentials.create.error') flash[:error] = t('webauthn_credentials.create.error')

+ 2
- 2
spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb View File

@ -248,7 +248,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
post :create, params: { credential: new_webauthn_credential, nickname: 'USB Key' } post :create, params: { credential: new_webauthn_credential, nickname: 'USB Key' }
expect(response).to have_http_status(500)
expect(response).to have_http_status(422)
expect(flash[:error]).to be_present expect(flash[:error]).to be_present
end end
end end
@ -268,7 +268,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
post :create, params: { credential: new_webauthn_credential, nickname: nickname } post :create, params: { credential: new_webauthn_credential, nickname: nickname }
expect(response).to have_http_status(500)
expect(response).to have_http_status(422)
expect(flash[:error]).to be_present expect(flash[:error]).to be_present
end end
end end

Loading…
Cancel
Save