Example #1
0
        public async Task <ActionResult> ConfirmEmail(int userId, string code, Guid codeHashed)
        {
            if (code == null || codeHashed == null)
            {
                return(View("Error"));
            }
            var foundInUser = Guid.Empty;
            var result      = await Manager.ConfirmEmailAsync(userId, code);

            if (result.Succeeded)
            {
                #region Complete Registration on sucess of confirmation.
                var user = UserManager.GetUser(userId);
                if (user != null)
                {
                    foundInUser = (Guid)user.GeneratedGuid;
                }
                if (!user.IsRegistrationComplete)
                {
                    if (foundInUser.Equals(codeHashed))
                    {
                        CallCompleteRegistration(userId);
                        UserManager.ClearUserSessions(); // clear user cache.
                        ViewBag.icon = FaIcons.CheckMark;
                        return(View("ConfirmEmail"));
                    }
                }
                else
                {
                    // already registered
                    ViewBag.message = "You have already registered and confirmed your email successfully.";
                    ViewBag.icon    = FaIcons.CheckMark;
                    return(View("InboxCheck"));
                }
                #endregion
            }
            AddErrors(result);
            return(AppVar.GetFriendlyError("Confirmation is not valid.",
                                           "Sorry your confirmation is not valid. Please try again from /account/verify."));
        }