public OTPModel SaveOTP(OTPModel model) { ///incomplete pls complete List <Parameter> param = new List <Parameter>(); var p_otpCode = new Parameter("@otpCode", model.otpCode); var p_otpMobileNo = new Parameter("@otpMobileNo", model.otpMobileNo); Parameter p_IsError = new Parameter("@IsError", DBNull.Value, ParameterDirection.Output, DbType.Int16, 1); Parameter p_ErrorMsg = new Parameter("@ErrorMsg", DBNull.Value, ParameterDirection.Output, DbType.String, 100); param.Add(p_otpCode); param.Add(p_otpMobileNo); param.Add(p_IsError); param.Add(p_ErrorMsg); var r = dataBaseService.ExecuteScalar(StoredProcedures.SaveOtp , DBCommandType.Procedure , param.ToArray() ); int retValue = Convert.ToInt32(r); if (retValue < (int)StoreProcStatusEnum.Success) { model.Success = false; model.ErrorMessage = p_ErrorMsg.ToString(); } else { model.Success = true; model.Id = retValue; } return(model); }
public async Task <IActionResult> EMAIL_OTP(OTPModel model) { dynamic code = Generate.GenerateVerificationCode(); if (ModelState.IsValid) { try { OTPLog oTPLog = new OTPLog { OTP = code, //Email = model.Email }; _context.OTPs.Add(oTPLog); _context.SaveChanges(); var subjectTo = "VERIFICATION CODE"; var messages = "</br><b> Verification code </b>" + code; messages += ("<br />"); messages += ("<br />"); messages += "</br>Regards"; await _emailSender.SendEmailAsync(model.Email, subjectTo, messages, ""); return(RedirectToAction(nameof(OTPNumbers), "Account", model.Email)); } catch (Exception xe) { throw xe; } } return(View(model)); }
public IActionResult Index() { var model = new OTPModel { }; return(View(model)); }
ActionOutput <UserModel> IUserManager.VeifyOTP(OTPModel model) { ActionOutput <UserModel> res = new ActionOutput <UserModel>(); try { var user = Context.UserTbls.Where(p => p.Id == model.Id && p.Status == (int)UserStatuss.Registered).FirstOrDefault(); if (user != null) { if (user.OTP == model.OTP.ToString()) { if (user.RoleId == (int)UserRoleTypes.Mother) { user.Status = (int)UserStatuss.Verified; MotherTbl _mother = new MotherTbl(); _mother.ApplicationNo = UtilitiesHelp.GenerateApplicationNo(); _mother.UserId = user.Id; _mother.WalletAmount = 0; _mother.Commision = 0; _mother.Ratings = 0; Context.MotherTbls.Add(_mother); Context.SaveChanges(); res.Object = new UserModel(user); res.Status = ActionStatus.Successfull; res.Message = "Mother Verified successfully. Wait for Admin approval."; } else { user.Status = (int)UserStatuss.Approved; Context.SaveChanges(); res.Object = new UserModel(user); res.Status = ActionStatus.Successfull; res.Message = "User Verified successfully"; } } else { res.Status = ActionStatus.Error; res.Message = "Incorrect OTP."; } } else { res.Status = ActionStatus.Error; res.Message = "User doesnt exists."; } } catch (Exception ex) { res.Status = ActionStatus.Error; res.Message = "Some Errpr Occurred"; } return(res); }
public otpViewmodel Map(OTPModel oTPModel) { return(new otpViewmodel { otpCode = oTPModel.otpCode, UserId = oTPModel.UserId, otpMobileNo = oTPModel.otpMobileNo }); }
public JsonResult SenderOTP([FromBody] OTPModel model) { if (ModelState.IsValid) { if (_optsender.OTPSenderUser(model.phone) == true) { return(Json(JsonResultResponse.ResponseChange("OTP sent successed."))); } } return(Json(JsonResultResponse.ResponseFail("OTP sent failed."))); }
public ActionResult VerifyOTP(string MobileNo = "9434553166", string ForgotPass = "******") { OTPModel obj = new OTPModel(); obj.MobileNo = MobileNo; obj.Type = ForgotPass; ApiConnection objApi = new ApiConnection(""); String Jasonstring = JsonConvert.SerializeObject(obj); string result = objApi.PostRecordtoApI("account", "RequestOTPWeb", Jasonstring); return(View(obj)); }
public ActionResult ConfirmPassword(OTPModel otpdata) { try { if (ModelState.IsValid) { var otpapp = Session["otp"]; var mobilenumber = Session["mobilenumber"]; if (otpdata.Otpvalue == otpapp.ToString()) { Session.Remove("otp"); Session.Remove("mobilenumber"); var userdetail = _mainobj.GetByMobile(mobilenumber.ToString()); if (userdetail != null) { FormsAuthentication.Initialize(); HttpContext currentContext = System.Web.HttpContext.Current; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, userdetail.clientname, DateTime.Now, DateTime.Now.AddMinutes(30), true, userdetail.userrole, FormsAuthentication.FormsCookiePath); string hash = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash); currentContext.Response.Cookies.Add(cookie); AuthenticateThisRequest(); } //ModelState.AddModelError("MobileLogin", "Your mobile number is not registerd with us."); return(RedirectToAction("Index", "Support")); } else { opttrycount++; if (opttrycount > 2) { Session.Remove("otp"); Session.Remove("mobilenumber"); ModelState.AddModelError("MobileLogin", "OTP is expired. To get new OTP, enter mobile number again."); return(View("Login")); } ViewBag.mobilenumber = mobilenumber; ModelState.AddModelError("Otpvalue", "OTP is not valid"); return(View("ConfirmOTP")); } } } catch { } return(View("Login")); }
public ActionResult VerifyOTP(OTPModel obj) { ApiConnection objApi = new ApiConnection(""); String Jasonstring = JsonConvert.SerializeObject(obj); string result = objApi.PostRecordtoApI("account", "VerifyOTPWeb", Jasonstring); if (result == "Success") { return(RedirectToAction("Index", "Home")); } else { ViewBag.Message = result; } return(View(obj)); }
public IActionResult OTPNumbers(OTPModel model) { if (ModelState.IsValid) { var otp = _context.OTPs.SingleOrDefault(x => x.OTP == model.OTP); if (otp == null) { throw new Exception("OTP is not valid"); } else { return(RedirectToAction("RegisterLoan", "Loan", model.Email)); //return RedirectToAction("RegisterClient", "Account", model.Email); } } return(View(model)); }
public async Task Send_Number() { if (ic.connectivity()) { progress = new Android.App.ProgressDialog(Activity); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetCancelable(false); progress.SetMessage("Please wait..."); progress.Show(); OTPModel otp_data = new OTPModel(); otp_data.MobileNo = number; otp_data.SMS = "OTP"; string otp_json = JsonConvert.SerializeObject(otp_data); try { string item = await restService.GetOtp(Activity, licenceid, geolocation, version, otp_json); if (item.Contains("Authentication Failed")) { progress.Dismiss(); AlertBox(); } else { var primeArray = item.Split(','); otp = primeArray[0]; otp = otp.Substring(1); username = primeArray[1]; progress.Dismiss(); verification(); } } catch (Exception e) { progress.Dismiss(); } } else { progress.Dismiss(); } }
public HttpResponseMessage VerifyUser([FromBody] OTPModel model) { if (model == null) { throw new HttpResponseException(new HttpResponseMessage() { StatusCode = HttpStatusCode.Unauthorized, Content = new StringContent("Please provide the required fields.") }); } var result = _userManager.VeifyOTP(model); if (result.Status == ActionStatus.Successfull) { var token = CreateNewSession(result.Object.UserID); result.Object.SessionId = Guid.Parse(token); return(new JsonContent(result.Message, Status.Success, new { user = result.Object }).ConvertToHttpResponseOK()); } else { return(new JsonContent("Error While SignUp", Status.Failed, result).ConvertToHttpResponseOK()); } }
private async void SubmitButton_Clicked(object sender, EventArgs e) { NoInternet.IsVisible = false; Loader.IsVisible = true; await Task.Delay(1000); if (user_Id != null) { HttpRequestWrapper wrapper = new HttpRequestWrapper(); List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); OTPModel OModel = new OTPModel(); if (ChkNullAll() == true) { parameters.Add(new KeyValuePair <string, string>("company_code", Constant.CompanyID)); parameters.Add(new KeyValuePair <string, string>("otp", OTP.Text.Trim())); parameters.Add(new KeyValuePair <string, string>("user_id", user_Id)); parameters.Add(new KeyValuePair <string, string>("device_type", Constant.DeviceType)); parameters.Add(new KeyValuePair <string, string>("device_token", Constant.DeviceToken)); parameters.Add(new KeyValuePair <string, string>("app_version", Constant.AppVersion)); try { string data = await wrapper.GetResponseAsync(Constant.APIs[(int)Constant.APIName.OTP], parameters); if (data.ToString() == "NoInternet") { NoInternet.IsVisible = true; MainContainer.IsVisible = false; logoimg.IsVisible = false; } else { try { des = JsonConvert.DeserializeObject <LoginModel>(data); } catch { await DisplayAlert("Internal server error", "Please try again later", "Cancel"); } if (des.responseText == "Success") { AppData.IsLogin = true; AppData.UserName = des.data.user_data.name; AppData.UserId = des.data.user_data.user_id; AppData.UserCityId = des.data.user_data.city_id; AppData.UserCity = des.data.user_data.city_name; AppData.Avatar = des.data.user_data.avatar; App.Current.MainPage = new MasterDetailsPage(); } else { //Invalid await DisplayAlert("Error", des.responseText, "Cancel"); } } } catch (Exception ex) { } } } Loader.IsVisible = false; MainContainer.IsVisible = true; }