コード例 #1
0
        public async Task <IActionResult> ConfirmEmail(string userId, string code)
        {
            if (signInManager.IsSignedIn(User))
            {
                return(this.RedirectToSiteRoot(Site));
            }
            if (userId == null || code == null)
            {
                return(View("Error"));
            }
            var user = await userManager.FindByIdAsync(userId);

            if (user == null)
            {
                return(View("Error"));
            }
            var result = await userManager.ConfirmEmailAsync(user, code);

            if (result.Succeeded)
            {
                if (Site.RequireApprovalBeforeLogin && !user.AccountApproved)
                {
                    await emailSender.AccountPendingApprovalAdminNotification(Site, user).ConfigureAwait(false);

                    return(RedirectToAction("PendingApproval", new { userId = user.Id, didSend = true }));
                }
            }

            return(View(result.Succeeded ? "ConfirmEmail" : "Error"));
        }
コード例 #2
0
        public async Task <VerifyEmailResult> ConfirmEmailAsync(string userId, string code)
        {
            IUserContext   userContext = null;
            IdentityResult result      = IdentityResult.Failed(null);

            var user = await userManager.FindByIdAsync(userId);

            if (user != null)
            {
                userContext = new UserContext(user);
                result      = await userManager.ConfirmEmailAsync(user, code);
            }

            return(new VerifyEmailResult(userContext, result));
        }
コード例 #3
0
        public async Task <IActionResult> ConfirmEmail(string userId, string code)
        {
            if (userId == null || code == null)
            {
                return(View("Error"));
            }
            var user = await userManager.FindByIdAsync(userId);

            if (user == null)
            {
                return(View("Error"));
            }
            var result = await userManager.ConfirmEmailAsync(user, code);

            return(View(result.Succeeded ? "ConfirmEmail" : "Error"));
        }
コード例 #4
0
        public async Task<IActionResult> ConfirmEmail(string userId, string code)
        {

            if (userId == null || code == null)
            {
                return View("Error");
            }
            var user = await userManager.FindByIdAsync(userId);
            if (user == null)
            {
                return View("Error");
            }
            var result = await userManager.ConfirmEmailAsync(user, code);
            
            if (Site.RequireApprovalBeforeLogin && ! user.AccountApproved)
            {
                emailSender.AccountPendingApprovalAdminNotification(Site, user).Forget();

                return RedirectToAction("PendingApproval", new { userId = user.Id, didSend = true });
            }

            return View(result.Succeeded ? "ConfirmEmail" : "Error");
        }