Beispiel #1
0
        public async void ConfirmAccount(ConfirmAccountPageModel tConfirmAccountPageModel)
        {

            var vGood = false;

            if (ModelValidator.IsValid(tConfirmAccountPageModel))
            {
                var vCommand =
                    mAccountCommandFactory.CreateLoginAccountCommand(
                        tConfirmAccountPageModel);

                if (await vCommand.Execute())
                {
                    var vModel = new ConfirmAccountModel
                                     {
                                         Name = tConfirmAccountPageModel.Name,
                                         ConfirmationNumber =
                                             tConfirmAccountPageModel
                                             .ConfirmationNumber
                                     };
                    var vConfirmCommand =
                        mAccountCommandFactory.CreateConfirmAccountCommand(vModel);
                    vGood = vConfirmCommand.Execute();
                }
            }

            Caller.AddConfirmation(vGood);
        }
Beispiel #2
0
 public ActionResult ConfirmAccount(ConfirmAccountModel model)
 {
     if (WebSecurity.ConfirmAccount(model.Token))
     {
         return(RedirectToAction("Login", "Account"));
     }
     else
     {
         ModelState.AddModelError("", "Invalid confirmation token");
     }
     return(View(model));
 }
Beispiel #3
0
        public async Task <IActionResult> ConfirmAccount(ConfirmAccountModel model)
        {
            if (!string.IsNullOrEmpty(model.UserId))
            {
                var user = await _userManager.FindByIdAsync(model.UserId);

                if (user != null)
                {
                    await _userService.SendInviteAsync(user);
                }
                else
                {
                    _logger.LogWarning("An account confirmation link was requested for non-existing user id {userId}", model.UserId);
                }
            }
            return(RedirectToAction(nameof(ConfirmAccountLinkSent)));
        }
        public void SetsConfirmationToTrue(string tName, string tPassword, string tEmail, int tNumber)
        {
            var vDataStore = GetEmbeddedDatabase;
            AddAccountToDataStore(vDataStore, tName, tPassword, tEmail, tNumber);

            var vModel = new ConfirmAccountModel
                             {
                                 Name = tName,
                                 ConfirmationNumber = tNumber
                             };

            var vCommand = new ConfirmAccountCommand(vDataStore, vModel);
            vCommand.Execute();

            using (var vSession = vDataStore.OpenSession())
            {
                var vAccount = vSession.Load<Account>("Accounts/" + tName);
                Assert.AreEqual(true, vAccount.IsConfirmed);
            }
        }
Beispiel #5
0
        public async Task <IActionResult> ConfirmAccount(string userId, string code)
        {
            if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(code))
            {
                throw new ApplicationException($"Account confirmation failed for {userId} with code {code}");
            }

            var user = await _userManager.FindByIdAsync(userId);

            if (user == null)
            {
                throw new ApplicationException($"Can't find user {userId}");
            }
            if (user.EmailConfirmed)
            {
                return(View("ConfirmAccountAlreadyDone"));
            }

            var result = await _userManager.ConfirmEmailAsync(user, code);

            if (result.Succeeded)
            {
                _logger.LogInformation("Confirmed e-mail for user {userId} ({email})", userId, user.Email);
                // Resetting the security stamp invalidates the code so operation cannot be redone.
                await _userManager.UpdateSecurityStampAsync(user);

                await _signInManager.SignInAsync(user, true);

                var pToken = await _userManager.GeneratePasswordResetTokenAsync(user);

                return(RedirectToAction(nameof(RegisterNewAccount), new { userId, pToken }));
            }

            var model = new ConfirmAccountModel {
                UserId = userId
            };

            return(View("ConfirmAccountFailed", model));
        }