Commit 0c1ccda4 authored by Stan Hu's avatar Stan Hu

Add "Confirm user" button in user admin page

Closes #2116
Closes https://github.com/gitlabhq/gitlabhq/issues/9502
parent 4c9ba632
......@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 7.14.0 (unreleased)
- Fix multi-line syntax highlighting (Stan Hu)
- Fix network graph when branch name has single quotes (Stan Hu)
- Add "Confirm user" button in user admin page (Stan Hu)
- Upgrade gitlab_git to version 7.2.6 to fix Error 500 when creating network graphs (Stan Hu)
- Add support for Unicode filenames in relative links (Hiroyuki Sato)
- Fix URL used for refreshing notes if relative_url is present (Bartłomiej Święcki)
......
......@@ -55,6 +55,14 @@ class Admin::UsersController < Admin::ApplicationController
end
end
def confirm
if user.confirm!
redirect_to :back, notice: "Successfully confirmed"
else
redirect_to :back, alert: "Error occurred. User was not confirmed"
end
end
def disable_two_factor
user.disable_two_factor!
redirect_to admin_user_path(user),
......
......@@ -105,6 +105,16 @@
.col-md-6
- unless @user == current_user
- unless @user.confirmed?
.panel.panel-info
.panel-heading
Confirm user
.panel-body
- if @user.unconfirmed_email.present?
- email = " (#{@user.unconfirmed_email})"
%p This user has an unconfirmed email address#{email}. You may force a confirmation.
%br
= link_to 'Confirm user', confirm_admin_user_path(@user), method: :put, class: "btn btn-info", data: { confirm: 'Are you sure?' }
- if @user.blocked?
.panel.panel-info
.panel-heading
......
......@@ -159,6 +159,7 @@ Gitlab::Application.routes.draw do
put :block
put :unblock
put :unlock
put :confirm
patch :disable_two_factor
delete 'remove/:email_id', action: 'remove_email', as: 'remove_email'
end
......
......@@ -37,6 +37,20 @@ describe Admin::UsersController do
end
end
describe 'PUT confirm/:id' do
let(:user) { create(:user, confirmed_at: nil) }
before do
request.env["HTTP_REFERER"] = "/"
end
it 'confirms user' do
put :confirm, id: user.username
user.reload
expect(user.confirmed?).to be_truthy
end
end
describe 'PATCH disable_two_factor' do
let(:user) { create(:user) }
......
......@@ -184,6 +184,19 @@ describe User do
it { is_expected.to respond_to(:private_token) }
end
describe '#confirm' do
let(:user) { create(:user, confirmed_at: nil, unconfirmed_email: 'test@gitlab.com') }
it 'returns unconfirmed' do
expect(user.confirmed?).to be_falsey
end
it 'confirms a user' do
user.confirm!
expect(user.confirmed?).to be_truthy
end
end
describe '#to_reference' do
let(:user) { create(:user) }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment