diff options
-rw-r--r-- | app/controllers/settings/identity_proofs_controller.rb | 12 | ||||
-rw-r--r-- | app/views/settings/identity_proofs/_proof.html.haml | 1 | ||||
-rw-r--r-- | config/locales/en.yml | 4 | ||||
-rw-r--r-- | config/routes.rb | 2 | ||||
-rw-r--r-- | spec/controllers/settings/identity_proofs_controller_spec.rb | 20 |
5 files changed, 32 insertions, 7 deletions
diff --git a/app/controllers/settings/identity_proofs_controller.rb b/app/controllers/settings/identity_proofs_controller.rb index a749d8020..3a90b7c4d 100644 --- a/app/controllers/settings/identity_proofs_controller.rb +++ b/app/controllers/settings/identity_proofs_controller.rb @@ -21,8 +21,7 @@ class Settings::IdentityProofsController < Settings::BaseController if current_account.username.casecmp(params[:username]).zero? render layout: 'auth' else - flash[:alert] = I18n.t('identity_proofs.errors.wrong_user', proving: params[:username], current: current_account.username) - redirect_to settings_identity_proofs_path + redirect_to settings_identity_proofs_path, alert: I18n.t('identity_proofs.errors.wrong_user', proving: params[:username], current: current_account.username) end end @@ -34,11 +33,16 @@ class Settings::IdentityProofsController < Settings::BaseController PostStatusService.new.call(current_user.account, text: post_params[:status_text]) if publish_proof? redirect_to @proof.on_success_path(params[:user_agent]) else - flash[:alert] = I18n.t('identity_proofs.errors.failed', provider: @proof.provider.capitalize) - redirect_to settings_identity_proofs_path + redirect_to settings_identity_proofs_path, alert: I18n.t('identity_proofs.errors.failed', provider: @proof.provider.capitalize) end end + def destroy + @proof = current_account.identity_proofs.find(params[:id]) + @proof.destroy! + redirect_to settings_identity_proofs_path, success: I18n.t('identity_proofs.removed') + end + private def check_required_params diff --git a/app/views/settings/identity_proofs/_proof.html.haml b/app/views/settings/identity_proofs/_proof.html.haml index 524827ad7..14e8e91be 100644 --- a/app/views/settings/identity_proofs/_proof.html.haml +++ b/app/views/settings/identity_proofs/_proof.html.haml @@ -18,3 +18,4 @@ %td = table_link_to 'external-link', t('identity_proofs.view_proof'), proof.badge.proof_url if proof.badge.proof_url + = table_link_to 'trash', t('identity_proofs.remove'), settings_identity_proof_path(proof), method: :delete, data: { confirm: t('admin.accounts.are_you_sure') } diff --git a/config/locales/en.yml b/config/locales/en.yml index 8a7cf070f..cc34b9094 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -844,12 +844,14 @@ en: invalid_token: Keybase tokens are hashes of signatures and must be 66 hex characters verification_failed: Keybase does not recognize this token as a signature of Keybase user %{kb_username}. Please retry from Keybase. wrong_user: Cannot create a proof for %{proving} while logged in as %{current}. Log in as %{proving} and try again. - explanation_html: Here you can cryptographically connect your other identities, such as a Keybase profile. This lets other people send you encrypted messages and trust content you send them. + explanation_html: Here you can cryptographically connect your other identities from other platforms, such as Keybase. This lets other people send you encrypted messages on those platforms and allows them to trust that the content you send them comes from you. i_am_html: I am %{username} on %{service}. identity: Identity inactive: Inactive publicize_checkbox: 'And toot this:' publicize_toot: 'It is proven! I am %{username} on %{service}: %{url}' + remove: Remove proof from account + removed: Successfully removed proof from account status: Verification status view_proof: View proof imports: diff --git a/config/routes.rb b/config/routes.rb index fa6639138..920a48fe7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -130,7 +130,7 @@ Rails.application.routes.draw do resource :confirmation, only: [:new, :create] end - resources :identity_proofs, only: [:index, :show, :new, :create, :update] + resources :identity_proofs, only: [:index, :new, :create, :destroy] resources :applications, except: [:edit] do member do diff --git a/spec/controllers/settings/identity_proofs_controller_spec.rb b/spec/controllers/settings/identity_proofs_controller_spec.rb index 261e980d4..16f236227 100644 --- a/spec/controllers/settings/identity_proofs_controller_spec.rb +++ b/spec/controllers/settings/identity_proofs_controller_spec.rb @@ -151,7 +151,7 @@ describe Settings::IdentityProofsController do @proof1 = Fabricate(:account_identity_proof, account: user.account) @proof2 = Fabricate(:account_identity_proof, account: user.account) allow_any_instance_of(AccountIdentityProof).to receive(:badge) { double(avatar_url: '', profile_url: '', proof_url: '') } - allow_any_instance_of(AccountIdentityProof).to receive(:refresh!) { } + allow_any_instance_of(AccountIdentityProof).to receive(:refresh!) {} end it 'has the first proof username on the page' do @@ -165,4 +165,22 @@ describe Settings::IdentityProofsController do end end end + + describe 'DELETE #destroy' do + before do + allow_any_instance_of(ProofProvider::Keybase::Verifier).to receive(:valid?) { true } + @proof1 = Fabricate(:account_identity_proof, account: user.account) + allow_any_instance_of(AccountIdentityProof).to receive(:badge) { double(avatar_url: '', profile_url: '', proof_url: '') } + allow_any_instance_of(AccountIdentityProof).to receive(:refresh!) {} + delete :destroy, params: { id: @proof1.id } + end + + it 'redirects to :index' do + expect(response).to redirect_to settings_identity_proofs_path + end + + it 'removes the proof' do + expect(AccountIdentityProof.where(id: @proof1.id).count).to eq 0 + end + end end |