Example #1
0
        public ActionResult Verify(string key, string hashtoken)
        {
            try
            {
                if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(hashtoken))
                {
                    var arrayVakue = TicketSecurityManager.SplitToken(key);
                    if (arrayVakue != null)
                    {
                        // arrayVakue[1] "UserId"
                        var rvModel = _verificationRepository.GetResetGeneratedToken(arrayVakue[1]);
                        if (rvModel != null)
                        {
                            var result = TicketSecurityManager.IsTokenValid(arrayVakue, hashtoken, rvModel.GeneratedToken);

                            if (result == 1)
                            {
                                TempData["TokenMessage"] = "Sorry Verification Link Expired Please request a new Verification link!";
                                return(RedirectToAction("Login", "Login"));
                            }

                            if (result == 2)
                            {
                                TempData["TokenMessage"] = "Sorry Verification Link Expired Please request a new Verification link!";
                                return(RedirectToAction("Login", "Login"));
                            }

                            if (result == 0)
                            {
                                Session["VerificationUserId"] = arrayVakue[1];
                                Session["ActiveVerification"] = "1";

                                return(RedirectToAction("Reset", "PasswordReset"));
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                TempData["TokenMessage"] = "Sorry Verification Failed Please request a new Verification link!";
                return(RedirectToAction("Login", "Login"));
            }

            TempData["TokenMessage"] = "Sorry Verification Failed Please request a new Verification link!";
            return(RedirectToAction("Login", "Login"));
        }
Example #2
0
        public ActionResult Verify(string key, string hashtoken)
        {
            try
            {
                if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(hashtoken))
                {
                    var arrayVakue = TicketSecurityManager.SplitToken(key);
                    if (arrayVakue != null)
                    {
                        // arrayVakue[1] "UserId"
                        var rvModel = _verificationRepository.GetRegistrationGeneratedToken(arrayVakue[1]);
                        if (rvModel != null)
                        {
                            var result = TicketSecurityManager.IsTokenValid(arrayVakue, hashtoken, rvModel.GeneratedToken);

                            if (_verificationRepository.CheckIsAlreadyVerifiedRegistration(Convert.ToInt64(arrayVakue[1])))
                            {
                                TempData["TokenErrorMessage"] = "Sorry Link is Expired";
                                return(RedirectToAction("Login", "Login"));
                            }

                            if (result == 1)
                            {
                                TempData["TokenErrorMessage"] = "Sorry Verification Link Expired Please request a new Verification link!";
                                return(RedirectToAction("Login", "Login"));
                            }

                            if (result == 2)
                            {
                                TempData["TokenErrorMessage"] = "Sorry Verification Link Expired Please request a new Verification link!";
                                return(RedirectToAction("Login", "Login"));
                            }

                            if (result == 0)
                            {
                                Session["VerificationUserId"] = arrayVakue[1];
                                var updateresult = _verificationRepository.UpdateRegisterVerification(Convert.ToInt64(arrayVakue[1]));
                                if (updateresult)
                                {
                                    TempData["Verify"] = "Done";
                                    return(RedirectToAction("Completed", "VerifyRegistration"));
                                }
                                else
                                {
                                    TempData["TokenErrorMessage"] = "Sorry Verification Failed Please request a new Verification link!";
                                    return(RedirectToAction("Login", "Login"));
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                TempData["TokenMessage"] = "Sorry Verification Failed Please request a new Verification link!";
                return(RedirectToAction("Login", "Login"));
            }

            TempData["TokenMessage"] = "Sorry Verification Failed Please request a new Verification link!";
            return(RedirectToAction("Login", "Login"));
        }