public ActionResult Impersonate(string ticket) { //Terminate existing user session _userAccessTokenProvider.DestroyAccessToken(); var newUser = _userService.ImpersonateUser(ticket); _userAccessTokenProvider.SetUserAccessToken(newUser); return(RedirectToAction("Index", "Me")); }
public ActionResult Index(LoginViewModel loginViewModel) { if (!ModelState.IsValid) { return(View(loginViewModel)); } try { var userCredentials = Mapper.Map <UserCredentials>(loginViewModel); //Attempt to login the user. This method will throw an exception if this fails. var accessToken = _userService.Login(userCredentials); _userAccessTokenProvider.SetUserAccessToken(accessToken); return(RedirectToAction("Index", "Home")); } catch (InvalidUserCredentialsException iuce) { ModelState.AddModelError("email", "Invalid email or password"); return(View(loginViewModel)); } }