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

View File

@ -16,12 +16,18 @@ class Settings::ProfilesController < Settings::BaseController
end
def update
if UpdateAccountService.new.call(@account, account_params)
ActivityPub::UpdateDistributionWorker.perform_async(@account.id)
redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg')
# 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
@account.build_fields
render :show
if UpdateAccountService.new.call(@account, account_params)
ActivityPub::UpdateDistributionWorker.perform_async(@account.id)
redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg')
else
@account.build_fields
render :show
end
end
end

View File

@ -6,7 +6,12 @@
.fields-row
.fields-row__column.fields-group.fields-row__column-6
= f.input :display_name, wrapper: :with_label, input_html: { maxlength: 30 }, hint: false
- 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 :note, wrapper: :with_label, input_html: { maxlength: 500 }, hint: false
.fields-row