Cannot stop impersonating user with missing e-mail address

Summary

As an admin, if I've chosen to impersonate a user who does not have an e-mail address in their profile, I cannot stop impersonating them and return to my personal role. Instead, I am simply redirected to their profile page and asked to supply an e-mail address.

Steps to reproduce

  1. Have a user sign up via OAuth, but not complete their profile (in our case, it was CAS)
  2. Sign in as an admin
  3. Impersonate the user created in step 1
  4. Attempt to stop impersonating them by clicking on the icon in the navbar

Expected behavior

You should return to your admin user role.

Actual behavior

You are redirected to /profile with the flash message Please complete your profile with email address.

Relevant logs and/or screenshots

Started DELETE "/admin/impersonation" for [FILTERED] at 2016-11-12 00:50:26 +0000
Processing by Admin::ImpersonationsController#destroy as HTML
Parameters: {"authenticity_token"=>"[FILTERED]"}
Redirected to https://[FILTERED]/profile
Filter chain halted as :require_email rendered or redirected
Completed 302 Found in 39ms (ActiveRecord: 3.1ms)
Started GET "/profile" for [FILTERED] at 2016-11-12 00:50:26 +0000
Processing by ProfilesController#show as HTML
Completed 200 OK in 107ms (Views: 69.3ms | ActiveRecord: 7.8ms)

(EDIT: I accidentally pasted in the logs from the start of impersonation, not from trying to end it)

Output of checks

Results of GitLab application Check

The UI says healthy - this is a GitHost instance so I don't have shell access.

Results of GitLab environment info

This is a GitHost instance so I don't have shell access.

Possible fixes

This before_action should have its guard clause modified to also exclude cases when the user is being impersonated.

https://gitlab.com/gitlab-org/gitlab-ee/blob/master/app/controllers/application_controller.rb#L23 https://gitlab.com/gitlab-org/gitlab-ee/blob/master/app/controllers/application_controller.rb#L230

Assignee Loading
Time tracking Loading