Allow admins to stop impersonating users without e-mail addresses
Resolves #24576 Modify the guard clause of the `ApplicationController#require_email` before action to skip requests where an admin is impersonating the current user.
This commit is contained in:
parent
694b55c828
commit
8dd9a8b6e0
|
@ -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
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: Allow admins to stop impersonating users without e-mail addresses
|
||||||
|
merge_request: 7550
|
||||||
|
author: Oren Kanner
|
|
@ -76,6 +76,7 @@ describe Admin::ImpersonationsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the impersonator is not blocked" do
|
context "when the impersonator is not blocked" do
|
||||||
|
shared_examples_for "successfully stops impersonating" do
|
||||||
it "redirects to the impersonated user's page" do
|
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
|
expect(Gitlab::AppLogger).to receive(:info).with("User #{impersonator.username} has stopped impersonating #{user.username}").and_call_original
|
||||||
|
|
||||||
|
@ -90,6 +91,19 @@ describe Admin::ImpersonationsController do
|
||||||
expect(warden.user).to eq(impersonator)
|
expect(warden.user).to eq(impersonator)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# base case
|
||||||
|
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
|
||||||
|
|
||||||
|
it_behaves_like "successfully stops impersonating"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue