forked from fedi/mastodon
compare usernames case-insensitively on new proof creation flow (#10544)
* compare usernames case-insensitively on new proof creation flow * Fix code style issue
This commit is contained in:
parent
9e2a1f1838
commit
154106c0c3
|
@ -18,7 +18,7 @@ class Settings::IdentityProofsController < Settings::BaseController
|
||||||
provider_username: params[:provider_username]
|
provider_username: params[:provider_username]
|
||||||
)
|
)
|
||||||
|
|
||||||
if current_account.username == params[:username]
|
if current_account.username.casecmp(params[:username]).zero?
|
||||||
render layout: 'auth'
|
render layout: 'auth'
|
||||||
else
|
else
|
||||||
flash[:alert] = I18n.t('identity_proofs.errors.wrong_user', proving: params[:username], current: current_account.username)
|
flash[:alert] = I18n.t('identity_proofs.errors.wrong_user', proving: params[:username], current: current_account.username)
|
||||||
|
|
|
@ -28,11 +28,11 @@ describe Settings::IdentityProofsController do
|
||||||
|
|
||||||
describe 'new proof creation' do
|
describe 'new proof creation' do
|
||||||
context 'GET #new' do
|
context 'GET #new' do
|
||||||
context 'with all of the correct params' do
|
|
||||||
before do
|
before do
|
||||||
allow_any_instance_of(ProofProvider::Keybase::Badge).to receive(:avatar_url) { full_pack_url('media/images/void.png') }
|
allow_any_instance_of(ProofProvider::Keybase::Badge).to receive(:avatar_url) { full_pack_url('media/images/void.png') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with all of the correct params' do
|
||||||
it 'renders the template' do
|
it 'renders the template' do
|
||||||
get :new, params: new_proof_params
|
get :new, params: new_proof_params
|
||||||
expect(response).to render_template(:new)
|
expect(response).to render_template(:new)
|
||||||
|
@ -54,6 +54,15 @@ describe Settings::IdentityProofsController do
|
||||||
expect(flash[:alert]).to eq I18n.t('identity_proofs.errors.wrong_user', proving: 'someone_else', current: user.account.username)
|
expect(flash[:alert]).to eq I18n.t('identity_proofs.errors.wrong_user', proving: 'someone_else', current: user.account.username)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with params to prove the same username cased differently' do
|
||||||
|
let(:capitalized_username) { new_proof_params.merge(username: user.account.username.upcase) }
|
||||||
|
|
||||||
|
it 'renders the new template' do
|
||||||
|
get :new, params: capitalized_username
|
||||||
|
expect(response).to render_template(:new)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'POST #create' do
|
context 'POST #create' do
|
||||||
|
|
Loading…
Reference in a new issue