Example #1
0
        public static string SendOTP(string UserName)
        {
            //divPassword.Attributes.CssStyle.Add("display", "none");
            //        divOTP.Attributes.CssStyle.Add("display", "block");
            //        divIncorrectOTP.Attributes.CssStyle.Add("display", "flex");
            //        divOTPSent.Attributes.CssStyle.Add("display", "block");
            //        rfvPwd.Enabled = false;
            //        rfvOTP.Enabled = true;
            string            MobileNumber = string.Empty;
            string            EmailId      = string.Empty;
            string            publicIp     = HttpContext.Current.Request.UserHostAddress;
            CardHolderManager chm          = new CardHolderManager();
            var cardHolder = chm.AuthenticateUser(UserName, publicIp);

            if (cardHolder != null)
            {
                CardManager cm   = new CardManager();
                CH_CardDTO  card = cm.GetCardByCreditCardNumber(new CH_CardDTO()
                {
                    Cr_Account_Nbr = cardHolder.creditcard_acc_number.Decrypt()
                });
                if (card != null)
                {
                    MobileNumber = hideMobileNumber = card.PHONE_MOBILE;
                    EmailId      = hideEmailId = card.EMAIL_ID;
                }
            }

            string MobileNum  = "";
            string OtpSuccess = string.Empty;
            string jsonresult = string.Empty;

            string OverRideEmail  = ConfigurationManager.AppSettings["OverRideUserEmail"];
            string OverRideMobile = ConfigurationManager.AppSettings["OverRideUserMobile"];

            MobileNum = MobileNumber.Substring(0, 6);
            strMobile = MobileNum.Replace(MobileNum, "xxxxxx") + MobileNumber.Substring(MobileNumber.Length - 4);
            try
            {
                if (OtpSuccess == null || OtpSuccess == string.Empty)
                {
                    if (!string.IsNullOrEmpty(OverRideMobile))
                    {
                        MobileNum = OverRideMobile;
                    }
                    if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["OverRideUserEmail"]))
                    {
                        EmailId = ConfigurationManager.AppSettings["OverRideUserEmail"];
                    }
                    OTPClient otp          = new OTPClient();
                    long      CardHolderId = CardHolderManager.GetLoggedInUser().CardHolder_Id;
                    OtpSuccess = otp.SendOTPRequest(MobileNumber, EmailId, Constants.ForgotUName, CardHolderId);
                    OTPval     = OtpSuccess;
                    if (OtpSuccess != "0" && !string.IsNullOrEmpty(OtpSuccess))
                    {
                        int strsec = 20;
                        jsonresult = OtpSuccess + "," + strMobile + "," + strsec;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(jsonresult);
        }
        public static string SendOTP(string CardNumber, string MobileNumber, string EmailId)
        {
            string MobileNum  = "";
            string OtpSuccess = string.Empty;
            string jsonresult = string.Empty;

            string OverRideEmail  = ConfigurationManager.AppSettings["OverRideUserEmail"];
            string OverRideMobile = ConfigurationManager.AppSettings["OverRideUserMobile"];

            MobileNum = MobileNumber.Substring(0, 6);
            string strMobile = MobileNum.Replace(MobileNum, "xxxxxx") + MobileNumber.Substring(MobileNumber.Length - 4);

            //Start Added by abhijeet on 09/10/2019 to restrict 3 OTP in one session with 20 sec wait time VAPT issue

            if (HttpContext.Current.Session["OTP_Count"] != null && HttpContext.Current.Session["OTP_Count"].ToString() != "")
            {
                int cnt = 0;
                if (Int32.TryParse(HttpContext.Current.Session["OTP_Count"].ToString(), out cnt) && cnt >= 3)
                {
                    return(jsonresult = Constants.MaxNoOfOTPMessage + ",");
                }
            }
            if (LastOTPSent != null && LastOTPSent.ToString() != "")
            {
                DateTime d;
                if (DateTime.TryParse(LastOTPSent.ToString(), out d))
                {
                    TimeSpan difference = DateTime.Now.Subtract(d);
                    if (difference.TotalSeconds < 20)
                    {
                        return(jsonresult = Constants.MaxNoOfOTPMessageForTime + ",");
                    }
                    else
                    {
                        jsonresult = "";
                    }
                }
            }
            //End Added by abhijeet on 09/10/2019 to restrict 3 OTP in one session VAPT issue

            try
            {
                if (OtpSuccess == null || OtpSuccess == string.Empty)
                {
                    if (!string.IsNullOrEmpty(OverRideMobile))
                    {
                        MobileNum = OverRideMobile;
                    }
                    if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["OverRideUserEmail"]))
                    {
                        EmailId = ConfigurationManager.AppSettings["OverRideUserEmail"];
                    }
                    OTPClient otp          = new OTPClient();
                    long      CardHolderId = CardHolderManager.GetLoggedInUser().CardHolder_Id;
                    OtpSuccess = otp.SendOTPRequest(MobileNumber, EmailId, Constants.ForgotUName, CardHolderId);
                    OTPval     = OtpSuccess;
                    //Start Added by abhijeet on 09/10/2019 to restrict 3 OTP in one session, VAPT issue
                    if (HttpContext.Current.Session["OTP_Count"] != null && HttpContext.Current.Session["OTP_Count"].ToString() != "")
                    {
                        int cnt = 0;
                        if (Int32.TryParse(HttpContext.Current.Session["OTP_Count"].ToString(), out cnt))
                        {
                            HttpContext.Current.Session["OTP_Count"] = cnt + 1;
                        }
                    }
                    else
                    {
                        HttpContext.Current.Session["OTP_Count"] = "1";
                    }
                    LastOTPSent = DateTime.Now;
                    //End Added by abhijeet on 09/10/2019 to restrict 3 OTP in one session VAPT, issue
                    if (OtpSuccess != "0" && !string.IsNullOrEmpty(OtpSuccess))
                    {
                        int strsec = 20;
                        jsonresult = OtpSuccess + "," + strMobile + "," + strsec;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(jsonresult);
        }