From badb94ff074cfd63e078d9f4d0f7198b8e0895a5 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Fri, 10 Nov 2017 15:05:43 -0500 Subject: Made the notification settings page not editable if user's email is not confirmed. --- app/views/users/edit_notifications.html.erb | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/app/views/users/edit_notifications.html.erb b/app/views/users/edit_notifications.html.erb index 9c45445..0976635 100644 --- a/app/views/users/edit_notifications.html.erb +++ b/app/views/users/edit_notifications.html.erb @@ -1,5 +1,11 @@ <% title "Edit Notification Settings: #{@user.name}" %> +<% + def can_edit? + (@user.is?(current_user) && confirmed?) || (mod? && current_user.role >= @user.role && current_user.confirmed?) + end +%> + <%= link_to @user.name, @user %> → Edit Notification Settings

Edit Notification Settings

@@ -11,13 +17,13 @@ replies to my thread - <%= f.check_box :mail_own_thread_reply %> + <%= f.check_box :mail_own_thread_reply, disabled: !can_edit? %> replies to a thread I already replied to - <%= f.check_box :mail_other_thread_reply %> + <%= f.check_box :mail_other_thread_reply, disabled: !can_edit? %> @@ -26,13 +32,13 @@ (Currently used for staff only) - <%= f.check_box :mail_own_blogpost_comment %> + <%= f.check_box :mail_own_blogpost_comment, disabled: !can_edit? %> comments a blog post I already commented - <%= f.check_box :mail_other_blogpost_comment %> + <%= f.check_box :mail_other_blogpost_comment, disabled: !can_edit? %> @@ -40,14 +46,20 @@ mentions me in a thread or comment - <%= f.check_box :mail_mention %> + <%= f.check_box :mail_mention, disabled: !can_edit? %>

Public Key

All notification emails will be encrypted with this key if you supply it.

- <%= f.text_area :public_key, placeholder: "-----BEGIN PGP PUBLIC KEY BLOCK-----" %> -

<%= f.submit "Save changes", class: "btn blue left" %>

+ <%= f.text_area :public_key, placeholder: "-----BEGIN PGP PUBLIC KEY BLOCK-----", disabled: !can_edit? %> +

<%= f.submit "Save changes", class: "btn blue left", disabled: !can_edit? %>

+ + <% if !@user.is?(current_user) && !current_user.confirmed? %> + You must confirm your own email before you can edit other user's notification settings. + <% elsif !@user.confirmed? && @user.is?(current_user) %> + You need to confirm your email before you can edit your notification settings. + <% end %> <% end %> -- cgit v1.2.3