public async Task ThenItShouldReturnAValidModel()
        {
            // Act
            var actual = await _orchestrator.StartRegistration(ClientId, ReturnUrl, false);

            // Assert
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Valid);
        }
コード例 #2
0
        public async Task <ActionResult> Register(string clientId, string returnUrl, string firstName, string lastName, string email)
        {
            if (string.IsNullOrEmpty(clientId))
            {
                clientId  = _owinWrapper.GetIdsClientId();
                returnUrl = _owinWrapper.GetIdsReturnUrl();
            }
            if (string.IsNullOrEmpty(returnUrl))
            {
                returnUrl = _owinWrapper.GetIdsReturnUrl();
            }

            var loginReturnUrl = Url.Action("Index", "Home", null, Request.Url.Scheme)
                                 + "identity/connect/authorize";
            var isLocalReturnUrl = returnUrl.ToLower().StartsWith(loginReturnUrl.ToLower());
            var model            = await _accountOrchestrator.StartRegistration(clientId, returnUrl, isLocalReturnUrl);

            if (!model.Valid)
            {
                return(new HttpStatusCodeResult((int)HttpStatusCode.BadRequest));
            }

            if (!string.IsNullOrWhiteSpace(firstName))
            {
                model.FirstName = firstName;
            }
            if (!string.IsNullOrWhiteSpace(lastName))
            {
                model.LastName = lastName;
            }
            if (!string.IsNullOrWhiteSpace(email))
            {
                model.Email = email;
            }

            _owinWrapper.RemovePartialLoginCookie();
            _owinWrapper.SignoutUser();

            HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity());

            var viewModel = new OrchestratorResponse <RegisterViewModel> {
                Data = model
            };

            return(View(viewModel));
        }