BigW Consortium Gitlab

Commit 45d69bf1 by Sean McGivern

Merge branch '24576_cant_stop_impersonating' into 'master'

Allow admins to stop impersonating users without e-mail addresses Closes #24576 See merge request !7550
parents 7902395f 8dd9a8b6
...@@ -224,7 +224,7 @@ class ApplicationController < ActionController::Base ...@@ -224,7 +224,7 @@ class ApplicationController < ActionController::Base
end end
def require_email def require_email
if current_user && current_user.temp_oauth_email? if current_user && current_user.temp_oauth_email? && session[:impersonator_id].nil?
redirect_to profile_path, notice: 'Please complete your profile with email address' and return redirect_to profile_path, notice: 'Please complete your profile with email address' and return
end end
end end
......
---
title: Allow admins to stop impersonating users without e-mail addresses
merge_request: 7550
author: Oren Kanner
...@@ -76,18 +76,32 @@ describe Admin::ImpersonationsController do ...@@ -76,18 +76,32 @@ describe Admin::ImpersonationsController do
end end
context "when the impersonator is not blocked" do context "when the impersonator is not blocked" do
it "redirects to the impersonated user's page" do shared_examples_for "successfully stops impersonating" do
expect(Gitlab::AppLogger).to receive(:info).with("User #{impersonator.username} has stopped impersonating #{user.username}").and_call_original it "redirects to the impersonated user's page" do
expect(Gitlab::AppLogger).to receive(:info).with("User #{impersonator.username} has stopped impersonating #{user.username}").and_call_original
delete :destroy delete :destroy
expect(response).to redirect_to(admin_user_path(user))
end
it "signs us in as the impersonator" do
delete :destroy
expect(response).to redirect_to(admin_user_path(user)) expect(warden.user).to eq(impersonator)
end
end end
it "signs us in as the impersonator" do # base case
delete :destroy it_behaves_like "successfully stops impersonating"
context "and the user has a temporary oauth e-mail address" do
before do
allow(user).to receive(:temp_oauth_email?).and_return(true)
allow(controller).to receive(:current_user).and_return(user)
end
expect(warden.user).to eq(impersonator) it_behaves_like "successfully stops impersonating"
end end
end end
end end
......
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