public ActionResult Set(ImpersonationStatus status)
        {
            if (status.Impersonating)
            {
                using (SwitchOrgScope(status.OrganisationId))
                {
                    var user = _getUserQuery.Invoke(new GetUserRequest
                    {
                        UserId         = status.UserId,
                        OrganisationId = status.OrganisationId
                    }).User;

                    if (user == null)
                    {
                        return(RedirectWithViewModel(status, "index", "Failed to find user with Id {0}".FormatWith(status.UserId)));
                    }

                    status.ExpiryUtc    = DateTime.Now.AddMinutes(30);
                    status.EmailAddress = user.Email;
                    _impersonationManager.Impersonate(status);
                }
            }
            else
            {
                _impersonationManager.StopImpersonating();
            }

            ConfirmationNotification("Success!");
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
 public ActionResult Signout()
 {
     _impersonationManager.StopImpersonating();
     _authenticationManager.SignOut();
     return(Redirect(Url.Home()));
 }