示例#1
0
        public async Task <IActionResult> Index(ChooseSessionViewModel chooseSessionViewModel)
        {
            try
            {
                var unprotectedUrl = _dataProtector.Unprotect(chooseSessionViewModel.ReturnUrl);
                var ticket         = _sessionManager.FetchTicket(HttpContext, chooseSessionViewModel.AccountName);
                if (ticket == null)
                {
                    return(new UnauthorizedResult());
                }

                await HttpContext.SignInAsync(ticket.Principal, new AuthenticationProperties());

                return(Redirect(unprotectedUrl));
            }
            catch (CryptographicException)
            {
                return(RedirectToAction("Index", "Errors", new { code = "invalid_request", ReturnUrl = $"{Request.Path}{Request.QueryString}" }));
            }
        }