Removed ability to change display name if account is verified

if account is verified, display name input in settings is not visible
if attempting to change the display name by other means, an error is return and you are redirected
This commit is contained in:
mgabdev 2019-07-04 02:01:50 -04:00
parent 70e3cef5a6
commit 4354c6ec99
2 changed files with 17 additions and 6 deletions

@ -16,6 +16,11 @@ class Settings::ProfilesController < Settings::BaseController
end end
def update def update
# if verified and display_name is different, return flash error and redirect back
if @account.is_verified && @account.display_name != params[:account][:display_name]
flash[:alert] = 'Unable to change Display name for verified account'
redirect_to settings_profile_path
else
if UpdateAccountService.new.call(@account, account_params) if UpdateAccountService.new.call(@account, account_params)
ActivityPub::UpdateDistributionWorker.perform_async(@account.id) ActivityPub::UpdateDistributionWorker.perform_async(@account.id)
redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg') redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg')
@ -24,6 +29,7 @@ class Settings::ProfilesController < Settings::BaseController
render :show render :show
end end
end end
end
private private

@ -6,6 +6,11 @@
.fields-row .fields-row
.fields-row__column.fields-group.fields-row__column-6 .fields-row__column.fields-group.fields-row__column-6
- if @account.is_verified
%span Verified accounts cannot changed display names
%br
%br
- else
= f.input :display_name, wrapper: :with_label, input_html: { maxlength: 30 }, hint: false = f.input :display_name, wrapper: :with_label, input_html: { maxlength: 30 }, hint: false
= f.input :note, wrapper: :with_label, input_html: { maxlength: 500 }, hint: false = f.input :note, wrapper: :with_label, input_html: { maxlength: 500 }, hint: false