public async Task <string> SendPhoneNumber(VerifyPhoneNumberBindingModel model) { var userid = await UserManager.FindByEmailAsync(model.Email); if (userid == null) { return("The email is not a registered user !"); } try { var phoneNumber = await UserManager.GetPhoneNumberAsync(userid.Id.ToString()); if (phoneNumber == null) { return("The phone number is not valid !"); } var code = await UserManager.GenerateChangePhoneNumberTokenAsync(userid.Id.ToString(), phoneNumber.ToString()); await UserManager.SendSmsAsync(userid.Id.ToString(), "Your FundooApp mobile number verification, the current code is " + code); } catch (Exception ex) { ex.ToString(); } return("Success"); }
public async Task <string> Verifyotp(VerifyPhoneNumberBindingModel model) { var userid = await UserManager.FindByEmailAsync(model.Username); // check if email is valid or not. if (userid == null) { return("The email is not a registered user !"); } var phoneNumber = await UserManager.GetPhoneNumberAsync(userid.Id.ToString()); // check if phone number valid if (phoneNumber == null) { return("The phone number is not valid !"); } var result = await UserManager.ChangePhoneNumberAsync(userid.Id.ToString(), phoneNumber, model.Code); if (result.Succeeded) { return("Success"); } return("Error"); }
//POST: api/WebApi/VerifyPhoneNumber public async Task Verifyotp(VerifyPhoneNumberBindingModel model) { if (ModelState.IsValid) { await objAccountService.Verifyotp(model); } }
//POST: api/WebApi/VerifyPhoneNumber public async Task VerifyPhoneNumber(VerifyPhoneNumberBindingModel model) { if (ModelState.IsValid) { await accountRepository.VerifyPhoneNumber(model); } }
public async Task <ActionResult> SendPhoneNumber(VerifyPhoneNumberBindingModel model) { if (ModelState.IsValid) { await WebApiController.SendPhoneNumber(model); } return(View("Login")); }
public async Task <ActionResult> Verifyotp(VerifyPhoneNumberBindingModel model) { if (!ModelState.IsValid) { return(View("Error")); } await AccountApicontroller.Verifyotp(model); return(View("Signin")); }
public void CheckCodeAsync(string name) { VerifyPhoneNumberBindingModel model = new VerifyPhoneNumberBindingModel { Username = name }; testmethodAsync(model); // await AccountApicontroller.SendPhoneNumber(model); }
public async Task <ActionResult> VerifyPhoneNumber(VerifyPhoneNumberBindingModel model) { if (!ModelState.IsValid) { return(View("Error")); } await WebApiController.VerifyPhoneNumber(model); return(View("Login")); }
public async Task <string> SendPhoneNumber(VerifyPhoneNumberBindingModel model) { //var userid = await UserManager.FindByEmailAsync(model.Username); var userid = UserManager.FindByEmail(model.Username); if (userid == null) { return("The email is not a registered user !"); } try { //taking phone number string strNewPhoneNumber = userid.PhoneNumber; var taskPhoneNumberSet = UserManager.SetPhoneNumberAsync(userid.Id, strNewPhoneNumber); taskPhoneNumberSet.Wait(); var phoneNumber = UserManager.GetPhoneNumberAsync(userid.Id); if (phoneNumber == null) { return("The phone number is not valid !"); } var code = await UserManager.GenerateChangePhoneNumberTokenAsync(userid.Id.ToString(), phoneNumber.Result.ToString()); await UserManager.SendSmsAsync(userid.Id.ToString(), "Your FundooApp mobile number verification, the current code is " + code); model.Code = code; } catch (Exception ex) { ex.ToString(); } return("Success"); }
public async Task testmethodAsync(VerifyPhoneNumberBindingModel model) { await AccountApicontroller.SendPhoneNumber(model); }