Merge pull request #1218 from joancodes/feature/add-email-visibility-toggle

Add profile toggle value to optionally show your e-mail address to authenticated users
This commit is contained in:
Peter Bhat Harkins 2023-11-15 15:20:11 +00:00 committed by GitHub
commit 88c7a4a972
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 7 deletions

View File

@ -271,7 +271,7 @@ class SettingsController < ApplicationController
:username, :email, :password, :password_confirmation, :homepage, :about,
:email_replies, :email_messages, :email_mentions,
:pushover_replies, :pushover_messages, :pushover_mentions,
:mailing_list_mode, :show_avatars, :show_story_previews,
:mailing_list_mode, :show_email, :show_avatars, :show_story_previews,
:show_submitted_story_threads, :prefers_color_scheme
)
end

View File

@ -68,6 +68,7 @@ class User < ApplicationRecord
s.boolean :pushover_messages, default: false
s.boolean :email_mentions, default: false
s.boolean :show_avatars, default: true
s.boolean :show_email, default: false
s.boolean :show_story_previews, default: false
s.boolean :show_submitted_story_threads, default: false
s.string :totp_secret

View File

@ -181,6 +181,15 @@
<h2>Miscellaneous Settings</h2>
<div class="boxline">
<%= f.label :show_email, "Show Email Address:",
:class => "required" %>
<%= f.check_box :show_email %>
<span class="hint indent">
Only shown to logged-in users
</span>
</div>
<div class="boxline">
<%= f.label :show_story_previews, "Show Story Previews:",
:class => "required" %>

View File

@ -100,6 +100,14 @@
<div style="clear: both;"></div>
<% end %>
<% if @user&.is_admin? || @user&.show_email? %>
<label class="required">E-Mail:</label>
<span class="d">
<%= @showing_user.email %>
</span>
<br>
<% end %>
<% if @showing_user.homepage.present? %>
<label class="required">Homepage:</label>
@ -203,12 +211,6 @@
<% if @user.is_admin? %>
<h3>Admin Information</h3>
<label class="required">E-Mail:</label>
<span class="d">
<%= @showing_user.email %>
</span>
<br>
<label class="required">Recent Votes:</label>
<table class="data zebra clear tall">
<% @showing_user.votes_for_others.limit(15).each do |v| %><tr>

View File

@ -0,0 +1,5 @@
class AddUserSettingShowEmail < ActiveRecord::Migration[7.0]
def change
add_column :users, :show_email, :boolean, default: false, null: false
end
end