public ActionResult ResendOTP() { var status = false; try { HelpingMethods hm = new HelpingMethods(); Session["otp"] = hm.RandomNumber(); string message = "OTP is " + Session["otp"].ToString() + " for login to brick kiln support."; var r = hm.sendsmsany(message, Session["mobilenumber"].ToString()); status = true; } catch { } return(new JsonResult { Data = new { status = status } }); }
//[ValidateAntiForgeryToken] public ActionResult Login(LoginModel model, string byotp, string bypassword) { if (ModelState.IsValid) { try { var localusermobile = model.MobileLogin.Trim(); if (localusermobile.All(char.IsDigit)) { if (localusermobile.Length == 10) { var userdetail = _mainobj.GetByMobile(localusermobile); if (userdetail == null) { ModelState.AddModelError("MobileLogin", "Mobile is not registered with us, please contact us to get registerd."); return(View()); } else { if (userdetail.userblocked) { ModelState.AddModelError("MobileLogin", "Your account is blocked by admin."); return(View()); } var currentwebsite = "Brick Kiln,"; var userforcuurentwebsite = userdetail.formodule.Contains(currentwebsite); if (!userforcuurentwebsite) { ModelState.AddModelError("MobileLogin", "Mobile is not registered with us for current website, please contact us to get registerd."); return(View()); } } if (!string.IsNullOrEmpty(byotp)) { HelpingMethods hm = new HelpingMethods(); Session["otp"] = hm.RandomNumber(); //Session["otp"] = 1111;/////////////////////////////////////// temp Session["mobilenumber"] = model.MobileLogin; ViewBag.mobilenumber = model.MobileLogin; string message = "OTP is " + Session["otp"].ToString() + " for login to brick kiln support."; var result = hm.sendsmsany(message, ViewBag.mobilenumber); Session["modelvalues"] = model; opttrycount = 0; return(View("ConfirmOTP")); } else if (!string.IsNullOrEmpty(bypassword)) { var upassword = StaticData.GetSHA512(model.Password); var loginresult = _mainobj.GetByMobilePassword(localusermobile, upassword); if (loginresult != null) { FormsAuthentication.Initialize(); HttpContext currentContext = System.Web.HttpContext.Current; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, loginresult.clientname, DateTime.Now, DateTime.Now.AddMinutes(30), true, loginresult.userrole, FormsAuthentication.FormsCookiePath); string hash = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash); currentContext.Response.Cookies.Add(cookie); AuthenticateThisRequest(); if (User.IsInRole("Admin")) { return(RedirectToAction("Index", "Description")); } else if (User.IsInRole("Support")) { return(RedirectToAction("ClientDetail", "Support")); } else if (User.IsInRole("Client")) { return(RedirectToAction("Index", "Support")); } } else { ModelState.AddModelError("MobileLogin", "Mobile or Password is not valid"); return(View("LoginAdmin")); } } } } } catch { } } ModelState.AddModelError("MobileLogin", "Mobile is not valid"); return(View()); }