FIX: Do not show Add or Change buttons if email is not editable (#10068)

FIX: Do not show Add or Change buttons if email is not editable (#10068)

diff --git a/app/assets/javascripts/discourse/app/templates/preferences/account.hbs b/app/assets/javascripts/discourse/app/templates/preferences/account.hbs
index 47df8c7..ed38031 100644
--- a/app/assets/javascripts/discourse/app/templates/preferences/account.hbs
+++ b/app/assets/javascripts/discourse/app/templates/preferences/account.hbs
@@ -50,9 +50,11 @@
         <div class="emails">
           {{#each emails as |email|}}
             <div class="row email">
-              {{email-dropdown email=email
-                              setPrimaryEmail=(action "setPrimaryEmail")
-                              destroyEmail=(action "destroyEmail")}}
+              {{#if model.can_edit_email}}
+                {{email-dropdown email=email
+                                setPrimaryEmail=(action "setPrimaryEmail")
+                                destroyEmail=(action "destroyEmail")}}
+              {{/if}}
 
               <div class="email-first">{{email.email}}</div>
 
@@ -77,9 +79,11 @@
           {{/each}}
         </div>
 
-        {{#link-to "preferences.email" (query-params new=1) class="pull-right"}}
-          {{d-icon "plus"}} {{i18n "user.email.add_email"}}
-        {{/link-to}}
+        {{#if model.can_edit_email}}
+          {{#link-to "preferences.email" (query-params new=1) class="pull-right"}}
+            {{d-icon "plus"}} {{i18n "user.email.add_email"}}
+          {{/link-to}}
+        {{/if}}
       {{else}}
         <div class="controls">
           <span class="static">{{model.email}}</span>

GitHub sha: 62faa0f5

This commit appears in #10068 which was approved by ZogStriP. It was merged by udan11.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/email-appears-editable-in-sso-section/156152/5