Skip to content

Commit

Permalink
Invert hide email logic to be possitive by default. (#3731)
Browse files Browse the repository at this point in the history
* Invert hide email logic to be possitive by default.

- makes email hidden by default
- add option to optionally show email in public profile during registration
  • Loading branch information
simi committed Sep 16, 2023
1 parent da7ac20 commit 25b3eef
Show file tree
Hide file tree
Showing 26 changed files with 762 additions and 783 deletions.
2 changes: 1 addition & 1 deletion app/avo/resources/user_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class UserResource < Avo::BaseResource

field :email_reset, as: :boolean
field :handle, as: :text
field :hide_email, as: :boolean
field :public_email, as: :boolean
field :twitter_username, as: :text, as_html: true, format_using: ->(value) { link_to value, "https://twitter.com/#{value}", target: :_blank, rel: :noopener if value.present? }
field :unconfirmed_email, as: :text

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def adoptions
private

def params_user
params.require(:user).permit(:handle, :twitter_username, :unconfirmed_email, :hide_email, :full_name).tap do |hash|
params.require(:user).permit(:handle, :twitter_username, :unconfirmed_email, :public_email, :full_name).tap do |hash|
hash.delete(:unconfirmed_email) if hash[:unconfirmed_email] == current_user.email
end
end
Expand Down
9 changes: 2 additions & 7 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class User < ApplicationRecord
bio
email
handle
hide_email
public_email
location
password
website
Expand Down Expand Up @@ -142,7 +142,7 @@ def all_hooks

def payload
attrs = { "id" => id, "handle" => handle }
attrs["email"] = email unless hide_email
attrs["email"] = email if public_email?
attrs
end

Expand Down Expand Up @@ -250,11 +250,6 @@ def ld_context
)
end

def hide_email=(value)
self[:hide_email] = value
self.public_email = !value
end

private

def update_email
Expand Down
9 changes: 0 additions & 9 deletions app/tasks/maintenance/backfill_user_public_email_task.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/mailer/gem_pushed.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<br/>
Pushed by user:
<strong>
<%= link_to @pushed_by_user.handle, profile_url(@pushed_by_user.display_id), target: "_blank" %> <%= mail_to(@pushed_by_user.email) unless @pushed_by_user.hide_email? %>
<%= link_to @pushed_by_user.handle, profile_url(@pushed_by_user.display_id), target: "_blank" %> <%= mail_to(@pushed_by_user.email) if @pushed_by_user.public_email? %>
</strong>
<br/>
Pushed at: <strong><%= @version.created_at.to_formatted_s(:rfc822) %></strong>
Expand Down
2 changes: 1 addition & 1 deletion app/views/mailer/gem_yanked.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<br/>
Yanked by user:
<strong>
<%= link_to @yanked_by_user.handle, profile_url(@yanked_by_user.display_id), target: "_blank" %> <%= mail_to(@yanked_by_user.email) unless @yanked_by_user.hide_email? %>
<%= link_to @yanked_by_user.handle, profile_url(@yanked_by_user.display_id), target: "_blank" %> <%= mail_to(@yanked_by_user.email) if @yanked_by_user.public_email? %>
</strong>
<br/>
Yanked at: <strong><%= @version.yanked_at.to_formatted_s(:rfc822) %></strong>
Expand Down
4 changes: 2 additions & 2 deletions app/views/profiles/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@


<div class="profile-checkbox form__checkbox">
<%= form.check_box :hide_email, :class => 'form__checkbox__input' %>
<%= form.label :hide_email, t('.hide_email'), :class => 'form__checkbox__label' %>
<%= form.check_box :public_email, :class => 'form__checkbox__input' %>
<%= form.label :public_email, t('profiles.public_email'), :class => 'form__checkbox__label' %>
</div>

<div class="submit_field">
Expand Down
2 changes: 1 addition & 1 deletion app/views/profiles/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
%>
</div>
<% else %>
<% unless @user.hide_email %>
<% if @user.public_email? %>
<p id="profile-email">
<%=
mail_to(
Expand Down
4 changes: 4 additions & 0 deletions app/views/users/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@
<%= form.label :password, t('activerecord.attributes.user.password'), :class => 'form__label' %>
<%= form.password_field :password, autocomplete: "new-password", class: 'form__input' %>
</div>
<div class="profile-checkbox form__checkbox">
<%= form.check_box :public_email, :class => 'form__checkbox__input' %>
<%= form.label :public_email, t('profiles.public_email'), :class => 'form__checkbox__label' %>
</div>
2 changes: 1 addition & 1 deletion config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ de:
change_avatar:
email_awaiting_confirmation:
enter_password:
hide_email: Verberge E-Mails in öffentlichem Profil
optional_full_name:
optional_twitter_username:
title: Bearbeite Profil
Expand All @@ -528,6 +527,7 @@ de:
update:
confirmation_mail_sent:
updated:
public_email: Anzeige E-Mails in öffentlichem Profil
request_denied:
show:
title: Profil von %{username}
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,6 @@ en:
change_avatar: Change Avatar
email_awaiting_confirmation: Please confirm your new email address %{unconfirmed_email}
enter_password: Please enter your account's password
hide_email: Hide email in public profile
optional_full_name: Optional. Will be displayed publicly
optional_twitter_username: Optional Twitter username. Will be displayed publicly
title: Edit profile
Expand All @@ -527,6 +526,7 @@ en:
update:
confirmation_mail_sent: You will receive an email within the next few minutes. It contains instructions for confirming your new email address.
updated: Your profile was updated.
public_email: Show email in public profile
request_denied: This request was denied. We could not verify your password.
show:
title: Profile of %{username}
Expand Down
2 changes: 1 addition & 1 deletion config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ es:
email_awaiting_confirmation: Por favor confirma tu nueva dirección de correo
%{unconfirmed_email}
enter_password: Por favor introduce tu contraseña
hide_email: Ocultar correo electrónico en perfil público
optional_full_name: Opcional. Será mostrado en tu perfil público
optional_twitter_username: Usuario de Twitter opcional. Será mostrado en tu
perfil público
Expand Down Expand Up @@ -558,6 +557,7 @@ es:
confirmation_mail_sent: Recibirás un correo electrónico en los próximos minutos.
Contiene instrucciones para confirmar tu nueva dirección de correo.
updated: Tu perfil se a actualizado.
public_email: Mostrar correo electrónico en perfil público
request_denied: La solicitud fue denegada. No pudimos verificar tu contraseña.
show:
title: Perfil de %{username}
Expand Down
2 changes: 1 addition & 1 deletion config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ fr:
email_awaiting_confirmation: Veuillez confirmer votre nouvelle adresse email
%{unconfirmed_email}
enter_password: Veuillez entrer le mot de passe de votre compte
hide_email: Ne pas afficher l'email dans le profil public
optional_full_name:
optional_twitter_username: Nom d'utilisateur Twitter optionnel. Sera affiché
publiquement
Expand Down Expand Up @@ -564,6 +563,7 @@ fr:
confirmation_mail_sent: Vous allez recevoir un email dans quelques minutes.
Il contient les instructions pour confirmer votre nouvelle adresse email.
updated: Votre profil a été mis à jour.
public_email: Afficher l'email dans le profil public
request_denied: Cette demande a été refusée. Nous n'avons pas pu vérifier votre
mot de passe.
show:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ ja:
change_avatar: アバターを変更
email_awaiting_confirmation: 新しいEメールアドレス%{unconfirmed_email}を確認してください。
enter_password: アカウントのパスワードを入力してください。
hide_email: Eメールアドレスを公開しない
optional_full_name: 省略可能です。公開されます。
optional_twitter_username: Twitterのユーザー名。省略可能です。公開されます。
title: プロフィールを編集
Expand All @@ -531,6 +530,7 @@ ja:
update:
confirmation_mail_sent: 数分でEメールが届きます。メールには新しいEメールアドレスを確認する手順が含まれています。
updated: プロフィールが更新されました。
public_email: メールアドレスを投稿する
request_denied: このリクエストは拒否されました。パスワードを検証できませんでした。
show:
title: "%{username} のプロフィール"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ nl:
change_avatar:
email_awaiting_confirmation:
enter_password:
hide_email:
optional_full_name:
optional_twitter_username:
title: Wijzig profiel
Expand All @@ -532,6 +531,7 @@ nl:
update:
confirmation_mail_sent:
updated:
public_email:
request_denied:
show:
title: Profiel van %{username}
Expand Down
2 changes: 1 addition & 1 deletion config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ pt-BR:
change_avatar: Mudar foto de perfil
email_awaiting_confirmation:
enter_password:
hide_email: Não mostrar meu email
optional_full_name:
optional_twitter_username:
title: Editar Perfil
Expand All @@ -543,6 +542,7 @@ pt-BR:
update:
confirmation_mail_sent:
updated:
public_email: Mostrar meu email
request_denied:
show:
title: Perfil de %{username}
Expand Down
2 changes: 1 addition & 1 deletion config/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ zh-CN:
change_avatar: 修改头像
email_awaiting_confirmation: 请确认您新的邮箱地址 %{unconfirmed_email}
enter_password: 请输入您账户的密码
hide_email: 在公开的个人资料里面隐藏我的邮箱
optional_full_name: 可填。将公开显示
optional_twitter_username: 可选 Twitter 用户名。这将会被公开显示
title: 修改个人资料
Expand All @@ -539,6 +538,7 @@ zh-CN:
update:
confirmation_mail_sent: 几分钟后您会收到一封邮件,它包含了确认您新邮箱地址的操作说明。
updated: 您的个人资料已更新
public_email: 在公开的个人资料里面展示我的 Email
request_denied: 请求被驳回,您的密码无法被我们验证通过。
show:
title: "%{username} 的个人资料"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ zh-TW:
change_avatar:
email_awaiting_confirmation: 請驗證你的新 Email %{unconfirmed_email}
enter_password: 輸入密碼
hide_email: 在公開的個人頁面中隱藏 email
optional_full_name:
optional_twitter_username: Twitter 帳號(可選)
title: 編輯個人檔案
Expand All @@ -515,6 +514,7 @@ zh-TW:
update:
confirmation_mail_sent:
updated:
public_email: 在公開的個人頁面中展示 email
request_denied:
show:
title: 简介 %{username}
Expand Down
5 changes: 2 additions & 3 deletions doc/erd.dot
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ m_Deletion [label = <<table border="0" align="center" cellspacing="0.5" cellpadd
</table>
|
<table border="0" align="left" cellspacing="2" cellpadding="0" width="134">
<tr><td align="left" width="130" port="number">number <font face="Arial Italic" color="grey60">string ∗</font></td></tr>
<tr><td align="left" width="130" port="platform">platform <font face="Arial Italic" color="grey60">string</font></td></tr>
<tr><td align="left" width="130" port="rubygem">rubygem <font face="Arial Italic" color="grey60">string ∗</font></td></tr>
</table>
Expand Down Expand Up @@ -437,7 +436,6 @@ m_Version [label = <<table border="0" align="center" cellspacing="0.5" cellpaddi
<tr><td align="left" width="130" port="latest">latest <font face="Arial Italic" color="grey60">boolean</font></td></tr>
<tr><td align="left" width="130" port="licenses">licenses <font face="Arial Italic" color="grey60">string</font></td></tr>
<tr><td align="left" width="130" port="metadata">metadata <font face="Arial Italic" color="grey60">hstore ∗</font></td></tr>
<tr><td align="left" width="130" port="number">number <font face="Arial Italic" color="grey60">string</font></td></tr>
<tr><td align="left" width="130" port="platform">platform <font face="Arial Italic" color="grey60">string</font></td></tr>
<tr><td align="left" width="130" port="position">position <font face="Arial Italic" color="grey60">integer</font></td></tr>
<tr><td align="left" width="130" port="prerelease">prerelease <font face="Arial Italic" color="grey60">boolean</font></td></tr>
Expand Down Expand Up @@ -497,14 +495,15 @@ m_WebauthnVerification [label = <<table border="0" align="center" cellspacing="0
m_OwnershipCall -> m_OwnershipRequest [arrowhead = "normal", arrowtail = "none", weight = "2"];
m_Rubygem -> m_OwnershipCall [arrowhead = "normal", arrowtail = "none", weight = "2"];
m_User -> m_OwnershipCall [arrowhead = "normal", arrowtail = "none", weight = "3"];
m_User -> m_Deletion [arrowhead = "normal", arrowtail = "none", weight = "3"];
m_ApiKey -> m_ApiKeyRubygemScope [arrowhead = "none", arrowtail = "none", weight = "2"];
m_Ownership -> m_ApiKeyRubygemScope [arrowhead = "normal", arrowtail = "none", weight = "2"];
"m_OIDC::Provider" -> m_Audit [arrowhead = "normal", arrowtail = "none", weight = "1"];
m_Rubygem -> m_Audit [arrowhead = "normal", arrowtail = "none", weight = "1"];
m_User -> m_Audit [arrowhead = "normal", arrowtail = "none", weight = "1"];
m_WebHook -> m_Audit [arrowhead = "normal", arrowtail = "none", weight = "1"];
"m_Admin::GitHubUser" -> m_Audit [arrowhead = "normal", arrowtail = "none", weight = "2"];
m_User -> m_Deletion [arrowhead = "normal", arrowtail = "none", weight = "3"];
m_Version -> m_Deletion [arrowhead = "none", arrowtail = "none", weight = "2"];
m_Rubygem -> m_Dependency [arrowhead = "normal", arrowtail = "none", weight = "1"];
m_Version -> m_Dependency [arrowhead = "normal", arrowtail = "none", weight = "2"];
m_Rubygem -> m_GemDownload [arrowhead = "none", arrowtail = "none", weight = "2"];
Expand Down

0 comments on commit 25b3eef

Please sign in to comment.