diff --git a/app/javascript/src/styles/base/040_colors.css b/app/javascript/src/styles/base/040_colors.css index 28eef86ec..5dc30e914 100644 --- a/app/javascript/src/styles/base/040_colors.css +++ b/app/javascript/src/styles/base/040_colors.css @@ -201,6 +201,9 @@ --user-member-color: var(--link-color); --user-banned-color: black; + --user-verified-email-color: #0A0; + --user-unverified-email-color: #F80; + --news-updates-background: #EEE; --news-updates-border: 2px solid #666; @@ -291,6 +294,9 @@ body[data-current-user-theme="dark"] { --user-moderator-color: var(--green-1); --user-admin-color: var(--red-1); + --user-verified-email-color: var(--green-1); + --user-unverified-email-color: var(--yellow-1); + /* misc specific colors */ --autocomplete-selected-background-color: var(--grey-3); --autocomplete-border: 1px solid var(--grey-4); diff --git a/app/javascript/src/styles/specific/users.scss b/app/javascript/src/styles/specific/users.scss index 708538025..ba9af319f 100644 --- a/app/javascript/src/styles/specific/users.scss +++ b/app/javascript/src/styles/specific/users.scss @@ -30,6 +30,14 @@ div#c-users { p { margin-bottom: 0.5em; } + + .user-verified-email-icon { + color: var(--user-verified-email-color); + } + + .user-unverified-email-icon { + color: var(--user-unverified-email-color); + } } } diff --git a/app/policies/email_address_policy.rb b/app/policies/email_address_policy.rb index cd92232d1..152469125 100644 --- a/app/policies/email_address_policy.rb +++ b/app/policies/email_address_policy.rb @@ -1,6 +1,6 @@ class EmailAddressPolicy < ApplicationPolicy def show? - record.user_id == user.id + record.user_id == user.id || (user.is_moderator? && record.user.level < user.level) end def update? diff --git a/app/policies/nil_class_policy.rb b/app/policies/nil_class_policy.rb new file mode 100644 index 000000000..8bce8769e --- /dev/null +++ b/app/policies/nil_class_policy.rb @@ -0,0 +1,21 @@ +class NilClassPolicy < ApplicationPolicy + def index? + false + end + + def show? + false + end + + def create? + false + end + + def update? + false + end + + def destroy? + false + end +end diff --git a/app/views/emails/verify.html.erb b/app/views/emails/verify.html.erb index 5790b4f57..f152a3558 100644 --- a/app/views/emails/verify.html.erb +++ b/app/views/emails/verify.html.erb @@ -6,12 +6,12 @@ <% if @user.is_restricted? %>

Your account is restricted because you signed up from a VPN or proxy. - You can still use the site, but you won't be able to leave comments, edit - tags, or upload posts until you verify your account.

+ You can still use the site, but you must verify your email address to be + able to leave comments, edit tags, or upload posts.

<% end %> -

Click below to send an email to <%= @email_address.address %> - to verify your account.

+

Your email address is unverified. Click below to send an email to + <%= @email_address.address %> to verify your email address.

<%= edit_form_for(@user, method: :post, url: send_confirmation_user_email_path(@user)) do |f| %> <%= f.submit "Send confirmation email" %> diff --git a/app/views/users/_statistics.html.erb b/app/views/users/_statistics.html.erb index 884a4c100..2a8ee6ec9 100644 --- a/app/views/users/_statistics.html.erb +++ b/app/views/users/_statistics.html.erb @@ -10,6 +10,7 @@ Join Date <%= presenter.join_date %> + <% if policy(IpAddress).show? %> Last IP @@ -27,6 +28,33 @@ <% end %> + <% if policy(user.email_address).show? %> + + Email Address + + <% if user.email_address.present? %> + <%= user.email_address.address %> + + <% if user == CurrentUser.user %> + (<%= link_to "edit", edit_user_email_path(user) %>) + <% end %> + + <% if user.email_address.is_verified? %> + + <% elsif user == CurrentUser.user %> + <%= link_to verify_user_email_path(user) do %> + + <% end %> + <% else %> + + <% end %> + <% else %> + none + <% end %> + + + <% end %> + Inviter <% if user.inviter %> diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 7d35e591f..5c2e2b583 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -114,7 +114,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest context "show action" do setup do # flesh out profile to get more test coverage of user presenter. - @user = create(:banned_user, can_approve_posts: true, created_at: 2.weeks.ago) + @user = create(:user, can_approve_posts: true, created_at: 2.weeks.ago) as(@user) do create(:saved_search, user: @user) create(:post, uploader: @user, tag_string: "fav:#{@user.name}") @@ -152,6 +152,33 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_equal(false, xml["user"]["enable_safe_mode"]) end + context "for a user with an email address" do + setup do + create(:email_address, user: @user) + end + + should "show the email address to the user themselves" do + get_auth user_path(@user), @user + + assert_response :success + assert_select ".user-email-address", count: 1 + end + + should "show the email address to mods" do + get_auth user_path(@user), create(:moderator_user) + + assert_response :success + assert_select ".user-email-address", count: 1 + end + + should "not show the email address to other users" do + get_auth user_path(@user), create(:user) + + assert_response :success + assert_select ".user-email-address", count: 0 + end + end + context "for a tooltip" do setup do @banned = create(:banned_user)