diff --git a/app/assets/stylesheets/components/buttons.css b/app/assets/stylesheets/components/buttons.css index c1269ce..d8730db 100644 --- a/app/assets/stylesheets/components/buttons.css +++ b/app/assets/stylesheets/components/buttons.css @@ -14,6 +14,10 @@ @apply py-1 px-2 text-sm; } + .btn-outline { + @apply border-2 border-gray-100 hover:bg-gray-100; + } + .btn-icon { @apply px-3; } diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 7a42a3e..f4168c3 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -88,6 +88,15 @@ class SettingsController < ApplicationController http_status :unprocessable_entity and return end + # DELETE /settings/nostr_pubkey + def remove_nostr_pubkey + current_user.update! nostr_pubkey: nil + + redirect_to setting_path(:experiments), flash: { + success: 'Public key removed from account' + } + end + private def set_main_nav_section diff --git a/app/views/settings/_experiments.html.erb b/app/views/settings/_experiments.html.erb index 4318db5..ef5bd4a 100644 --- a/app/views/settings/_experiments.html.erb +++ b/app/views/settings/_experiments.html.erb @@ -6,12 +6,37 @@ data-settings--nostr-pubkey-shared-secret-value="<%= session[:shared_secret] %>" data-settings--nostr-pubkey-pubkey-hex-value="<%= current_user.nostr_pubkey %>"> -

"> - +

+ + <%= link_to nostr_pubkey_settings_path, + class: 'btn-md btn-outline text-red-700 relative shrink-0', + data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' } do %> + Remove + <% end %>

- <% unless current_user.nostr_pubkey.present? %> + <% if current_user.nostr_pubkey.present? %> +
+
+
+ +
+
+

+ Your user address <%= current_user.address %> is + also a Nostr address now. Use your favorite Nostr app, or for + example metadata.nostr.com, to add this + NIP-05 address to your public profile. +

+
+
+
+ <% else %>

If you use any apps on the Nostr network, you can verify your public key with us in order to enable Nostr-specific features for your account. @@ -51,12 +76,14 @@ + <% unless current_user.nostr_pubkey.present? %>

-

+ <% end %> diff --git a/config/routes.rb b/config/routes.rb index 546d8ff..8668111 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -33,6 +33,7 @@ Rails.application.routes.draw do post 'update_email' post 'reset_password' post 'set_nostr_pubkey' + delete 'nostr_pubkey', to: 'settings#remove_nostr_pubkey' end end diff --git a/spec/features/settings/experiments_spec.rb b/spec/features/settings/experiments_spec.rb index e87bd1f..9931b35 100644 --- a/spec/features/settings/experiments_spec.rb +++ b/spec/features/settings/experiments_spec.rb @@ -19,4 +19,22 @@ RSpec.describe 'Experimental Settings', type: :feature do # worth it for now # end end + + context "With pubkey configured" do + before do + user.update! nostr_pubkey: "07e188a1ff87ce171d517b8ed2bb7a31b1d3453a0db3b15379ec07b724d232f3" + end + + scenario 'Remove nostr pubkey from account' do + visit settings_experiments_path + expect(page).to have_field("nostr_public_key", + with: "07e188a1ff87ce171d517b8ed2bb7a31b1d3453a0db3b15379ec07b724d232f3", + disabled: true) + + click_link "Remove" + expect(page).to_not have_field("nostr_public_key") + expect(page).to have_content("verify your public key") + expect(user.reload.nostr_pubkey).to be_nil + end + end end