示例#1
0
        public async Task <ActionResult> VerifyConfirmationCode(int id, string confirmationCode)
        {
            string executorName = null;

            try
            {
                executorName = await _executorService.ConfirmRegistration(id, confirmationCode);
            }
            catch (ValidationException e)
            {
                // there is no executor with such id, confirmation code and email confirmed
                return(new HttpStatusCodeResult(422));
            }

            Session["Name"] = executorName;
            Session["Id"]   = id;

            ClaimsIdentity claim = new ClaimsIdentity("ApplicationCookie");

            claim.AddClaim(new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider",
                                     "OWIN Provider", ClaimValueTypes.String));
            claim.AddClaim(new Claim(ClaimTypes.Role, Role.Executor.ToString(), ClaimValueTypes.String));

            _authenticationManager.SignOut();
            _authenticationManager.SignIn(new AuthenticationProperties
            {
                IsPersistent = false
            }, claim);

            return(RedirectToAction("Index", "Home"));
        }