Commit 780512ef authored by Rob Colbert's avatar Rob Colbert

Merge branch 'develop' of into develop

parents fda449bf f21f2651
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module Admin module Admin
class AccountsController < BaseController class AccountsController < BaseController
before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload, :remove_avatar, :remove_header, :enable, :unsilence, :unsuspend, :memorialize, :approve, :reject, :verify, :unverify, :add_donor_badge, :remove_donor_badge, :add_investor_badge, :remove_investor_badge, :edit_pro, :save_pro] before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload, :remove_avatar, :remove_header, :enable, :unsilence, :unsuspend, :memorialize, :approve, :reject, :verify, :unverify, :add_donor_badge, :remove_donor_badge, :add_investor_badge, :remove_investor_badge, :edit_pro, :save_pro, :edit, :update]
before_action :require_remote_account!, only: [:subscribe, :unsubscribe, :redownload] before_action :require_remote_account!, only: [:subscribe, :unsubscribe, :redownload]
before_action :require_local_account!, only: [:enable, :memorialize, :approve, :reject] before_action :require_local_account!, only: [:enable, :memorialize, :approve, :reject]
...@@ -173,6 +173,22 @@ module Admin ...@@ -173,6 +173,22 @@ module Admin
redirect_to edit_pro_admin_account_path( redirect_to edit_pro_admin_account_path(
end end
def edit
redirect_to admin_account_path( unless @account.local?
@user = @account.user
def update
redirect_to admin_account_path( unless @account.local?
@user = @account.user
if @user.update(credentials_params)
redirect_to admin_account_path(, notice: I18n.t('generic.changes_saved_msg')
render action: :edit
private private
def set_account def set_account
...@@ -211,5 +227,14 @@ module Admin ...@@ -211,5 +227,14 @@ module Admin
def pro_params def pro_params
params.require(:account).permit(:is_pro, :pro_expires_at) params.require(:account).permit(:is_pro, :pro_expires_at)
end end
def credentials_params
new_params = params.require(:user).permit(:email, :password, :password_confirmation)
if new_params[:password].blank? && new_params[:password_confirmation].blank?
end end
end end
...@@ -187,6 +187,6 @@ class FetchLinkCardService < BaseService ...@@ -187,6 +187,6 @@ class FetchLinkCardService < BaseService
def send_status_update_payload(status) def send_status_update_payload(status)
@payload = InlineRenderer.render(status, nil, :status) @payload = InlineRenderer.render(status, nil, :status)
@payload = Oj.dump(event: :update, payload: @payload) @payload = Oj.dump(event: :update, payload: @payload)
Redis.current.publish('statuscard', @payload) Redis.current.publish("statuscard:#{status.account_id}", @payload)
end end
end end
- content_for :page_title do
= t('admin.accounts.change_password.title', username: @account.acct)
= simple_form_for(@user, url: admin_account_path(, html: { method: :put }) do |f|
= render 'shared/error_messages', object: @user
= f.input :email, placeholder: t(''), input_html: { 'aria-label' => t('') }
= f.input :password, autocomplete: "off", placeholder: t('simple_form.labels.defaults.new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.new_password') }
= f.input :password_confirmation, autocomplete: "off", placeholder: t('simple_form.labels.defaults.confirm_new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_new_password') }
= f.button :button, t('admin.accounts.set_new_password'), type: :submit
\ No newline at end of file
...@@ -221,6 +221,9 @@ ...@@ -221,6 +221,9 @@
- elsif !@account.local? || @account.user_approved? - elsif !@account.local? || @account.user_approved?
= link_to t('admin.accounts.perform_full_suspension'), new_admin_account_action_path(, type: 'suspend'), class: 'button button--destructive' if can?(:suspend, @account) = link_to t('admin.accounts.perform_full_suspension'), new_admin_account_action_path(, type: 'suspend'), class: 'button button--destructive' if can?(:suspend, @account)
- if @account.local?
= link_to t('admin.accounts.change_password.button'), edit_admin_account_path(, class: 'button'
- unless @account.local? - unless @account.local?
- if DomainBlock.where(domain: @account.domain).exists? - if DomainBlock.where(domain: @account.domain).exists?
= link_to t('admin.domain_blocks.undo'), admin_instance_path(@account.domain), class: 'button' = link_to t('admin.domain_blocks.undo'), admin_instance_path(@account.domain), class: 'button'
...@@ -92,6 +92,10 @@ en: ...@@ -92,6 +92,10 @@ en:
new_email: New email new_email: New email
submit: Change email submit: Change email
title: Change email for %{username} title: Change email for %{username}
button: Change Password
title: Change password for %{username}
set_new_password: Update
confirm: Confirm confirm: Confirm
confirmed: Confirmed confirmed: Confirmed
confirming: Confirming confirming: Confirming
...@@ -182,7 +182,7 @@ Rails.application.routes.draw do ...@@ -182,7 +182,7 @@ Rails.application.routes.draw do
resources :report_notes, only: [:create, :destroy] resources :report_notes, only: [:create, :destroy]
resources :accounts, only: [:index, :show] do resources :accounts, only: [:index, :show, :edit, :update] do
member do member do
post :subscribe post :subscribe
post :unsubscribe post :unsubscribe
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment