Admin UI for confirming users (#2245)
* Shows confirmed status in list. * Adds ability to confirm users in admin UI. * Added new english translations. * Addresses feedback from #2245. * More feedback.
This commit is contained in:
parent
59b1de0bcf
commit
723f25a999
|
@ -0,0 +1,18 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Admin
|
||||||
|
class ConfirmationsController < BaseController
|
||||||
|
before_action :set_account
|
||||||
|
|
||||||
|
def create
|
||||||
|
@account.user.confirm
|
||||||
|
redirect_to admin_accounts_path
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_account
|
||||||
|
@account = Account.find(params[:account_id])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -19,6 +19,10 @@ class User < ApplicationRecord
|
||||||
scope :admins, -> { where(admin: true) }
|
scope :admins, -> { where(admin: true) }
|
||||||
scope :confirmed, -> { where.not(confirmed_at: nil) }
|
scope :confirmed, -> { where.not(confirmed_at: nil) }
|
||||||
|
|
||||||
|
def confirmed?
|
||||||
|
confirmed_at.present?
|
||||||
|
end
|
||||||
|
|
||||||
def send_devise_notification(notification, *args)
|
def send_devise_notification(notification, *args)
|
||||||
devise_mailer.send(notification, self, *args).deliver_later
|
devise_mailer.send(notification, self, *args).deliver_later
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
%tr
|
%tr
|
||||||
%th= t('admin.accounts.username')
|
%th= t('admin.accounts.username')
|
||||||
%th= t('admin.accounts.domain')
|
%th= t('admin.accounts.domain')
|
||||||
|
%th= t('admin.accounts.confirmed')
|
||||||
%th= fa_icon 'paper-plane-o'
|
%th= fa_icon 'paper-plane-o'
|
||||||
%th
|
%th
|
||||||
%tbody
|
%tbody
|
||||||
|
@ -34,6 +35,12 @@
|
||||||
%td
|
%td
|
||||||
- unless account.local?
|
- unless account.local?
|
||||||
= link_to account.domain, admin_accounts_path(by_domain: account.domain)
|
= link_to account.domain, admin_accounts_path(by_domain: account.domain)
|
||||||
|
%td
|
||||||
|
- if account.local?
|
||||||
|
- if account.user.present? && account.user.confirmed?
|
||||||
|
%i.fa.fa-check
|
||||||
|
- else
|
||||||
|
%i.fa.fa-times
|
||||||
%td
|
%td
|
||||||
- if account.local?
|
- if account.local?
|
||||||
= t('admin.accounts.location.local')
|
= t('admin.accounts.location.local')
|
||||||
|
|
|
@ -77,6 +77,9 @@
|
||||||
- else
|
- else
|
||||||
= link_to t('admin.accounts.silence'), admin_account_silence_path(@account.id), method: :post, class: 'button'
|
= link_to t('admin.accounts.silence'), admin_account_silence_path(@account.id), method: :post, class: 'button'
|
||||||
|
|
||||||
|
- unless @account.user.confirmed?
|
||||||
|
= link_to t('admin.accounts.confirm'), admin_account_confirmation_path(@account.id), method: :post, class: 'button'
|
||||||
|
|
||||||
- if @account.suspended?
|
- if @account.suspended?
|
||||||
= link_to t('admin.accounts.undo_suspension'), admin_account_suspension_path(@account.id), method: :delete, class: 'button'
|
= link_to t('admin.accounts.undo_suspension'), admin_account_suspension_path(@account.id), method: :delete, class: 'button'
|
||||||
- else
|
- else
|
||||||
|
|
|
@ -43,6 +43,8 @@ en:
|
||||||
admin:
|
admin:
|
||||||
accounts:
|
accounts:
|
||||||
are_you_sure: Are you sure?
|
are_you_sure: Are you sure?
|
||||||
|
confirm: Confirm
|
||||||
|
confirmed: Confirmed
|
||||||
display_name: Display name
|
display_name: Display name
|
||||||
domain: Domain
|
domain: Domain
|
||||||
edit: Edit
|
edit: Edit
|
||||||
|
|
|
@ -86,6 +86,7 @@ Rails.application.routes.draw do
|
||||||
resource :reset, only: [:create]
|
resource :reset, only: [:create]
|
||||||
resource :silence, only: [:create, :destroy]
|
resource :silence, only: [:create, :destroy]
|
||||||
resource :suspension, only: [:create, :destroy]
|
resource :suspension, only: [:create, :destroy]
|
||||||
|
resource :confirmation, only: [:create]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,18 @@ RSpec.describe User, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#confirmed?' do
|
||||||
|
it 'returns true when a confirmed_at is set' do
|
||||||
|
user = Fabricate.build(:user, confirmed_at: Time.now.utc)
|
||||||
|
expect(user.confirmed?).to be true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns false if a confirmed_at is nil' do
|
||||||
|
user = Fabricate.build(:user, confirmed_at: nil)
|
||||||
|
expect(user.confirmed?).to be false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'whitelist' do
|
describe 'whitelist' do
|
||||||
around(:each) do |example|
|
around(:each) do |example|
|
||||||
old_whitelist = Rails.configuration.x.email_whitelist
|
old_whitelist = Rails.configuration.x.email_whitelist
|
||||||
|
|
Loading…
Reference in New Issue