public async Task <ActionResult> VerifyOTP(VerifyOTPViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var result = await SignInManager.TwoFactorSignInAsync( model.Provider, model.Code, isPersistent : model.RememberMe, rememberBrowser : model.RememberBrowser); switch (result) { case SignInStatus.Success: return(RedirectToLocal(model.ReturnUrl)); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid code."); return(View(model)); } }
public IHttpActionResult VerifyOTP(VerifyOTPViewModel verifyOTP) { if (!Utilities.IsValidEmail(verifyOTP.Email)) { throw new Exception("Invalid email address.,"); } Guard.NotNullOrEmpty(verifyOTP.MobileNo, "Invalid mobile number for requesting OTP.,"); Guard.NotNullOrEmpty(verifyOTP.OTP, "Invalid OTP.,"); var mapuser = AutoMapper.Mapper.Map <User>(verifyOTP); var result = _serviceFactory.CreateUserService.VerifyOTP(mapuser); return(Ok(result)); }
public async Task <ActionResult> VerifyOTP(VerifyOTPViewModel viewModel) { if (!ModelState.IsValid) { return(View("OTP", viewModel)); } if (!string.IsNullOrWhiteSpace(viewModel.OTP)) { if (viewModel.OTP == Session["OTP"].ToString()) { await SignInManager.SignInAsync((ApplicationUser)Session["USER"], isPersistent : false, rememberBrowser : false); return(RedirectToAction("Index", "Home")); } } return(RedirectToAction("Login", "Register")); }