mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-23 05:11:53 +01:00
Add password reset for users from admin accounts area (#1841)
This commit is contained in:
parent
9d2f55ecc3
commit
6670e6d33f
4 changed files with 47 additions and 8 deletions
18
app/controllers/admin/resets_controller.rb
Normal file
18
app/controllers/admin/resets_controller.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ResetsController < BaseController
|
||||
before_action :set_account
|
||||
|
||||
def create
|
||||
@account.user.send_reset_password_instructions
|
||||
redirect_to admin_accounts_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_account
|
||||
@account = Account.find(params[:account_id])
|
||||
end
|
||||
end
|
||||
end
|
|
@ -61,6 +61,10 @@
|
|||
= surround '(', ')' do
|
||||
= number_to_human_size @account.media_attachments.sum('file_file_size')
|
||||
|
||||
%div{ style: 'float: right' }
|
||||
= link_to t('admin.accounts.reset_password'), admin_account_reset_path(@account.id), method: :create, class: 'button'
|
||||
|
||||
%div{ style: 'float: left' }
|
||||
- if @account.silenced?
|
||||
= link_to t('admin.accounts.undo_silenced'), admin_account_silence_path(@account.id), method: :delete, class: 'button'
|
||||
- else
|
||||
|
|
|
@ -86,6 +86,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
resources :accounts, only: [:index, :show] do
|
||||
resource :reset, only: [:create]
|
||||
resource :silence, only: [:create, :destroy]
|
||||
resource :suspension, only: [:create, :destroy]
|
||||
end
|
||||
|
|
16
spec/controllers/admin/resets_controller_spec.rb
Normal file
16
spec/controllers/admin/resets_controller_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Admin::ResetsController do
|
||||
let(:account) { Fabricate(:account, user: Fabricate(:user)) }
|
||||
before do
|
||||
sign_in Fabricate(:user, admin: true), scope: :user
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
it 'redirects to admin accounts page' do
|
||||
post :create, params: { account_id: account.id }
|
||||
|
||||
expect(response).to redirect_to(admin_accounts_path)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue