[#10966] Fix 500 when email is malformed

This commit is contained in:
Mathieu Magnin 2024-10-18 16:22:13 +02:00
parent fcb868c6a8
commit 478103b01a
No known key found for this signature in database
GPG key ID: 8DCAFC82D7BA654E
2 changed files with 9 additions and 1 deletions

View file

@ -2,6 +2,6 @@
class EmailCheckerController < ApplicationController
def show
render json: EmailChecker.check(email: params[:email])
render json: EmailChecker.check(email: params.permit(:email)[:email])
end
end

View file

@ -45,5 +45,13 @@ describe EmailCheckerController, type: :controller do
expect(body).to eq({ success: false })
end
end
context 'malformed' do
let(:params) { { email: { some: 'hash' } } }
it do
expect(response).to have_http_status(:success)
expect(body).to eq({ success: false })
end
end
end
end