Exception is raised when the impersonating administrator sign out the impersonated user
Description
An unhandled exception is raised leading to 500 error code when the impersonating administrator sign out the impersonated user.
Stacktrace
Redirected to https://gdk.test:3000/users/sign_in
Completed 500 Internal Server Error in 63ms (ActiveRecord: 2.9ms | Elasticsearch: 0.0ms | Allocations: 38288)
NoMethodError - undefined method `impersonator=' for nil:NilClass:
app/controllers/concerns/impersonation.rb:15:in `current_user'
app/controllers/application_controller.rb:56:in `block in <class:ApplicationController>'
app/controllers/application_controller.rb:490:in `set_current_admin'
lib/gitlab/session.rb:11:in `with_session'
app/controllers/application_controller.rb:481:in `set_session_storage'
Sentry - https://sentry.gitlab.net/gitlab/staginggitlabcom/issues/3182024
Steps to reproduce locally
- As an admin impersonate another user following this doc
- While impersonating click on the sign out button as shown in the image below. The exception should be raised.
Proposal
TBD
