示例#1
0
        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");
        }
示例#2
0
        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);
     }
 }
示例#4
0
 //POST: api/WebApi/VerifyPhoneNumber
 public async Task VerifyPhoneNumber(VerifyPhoneNumberBindingModel model)
 {
     if (ModelState.IsValid)
     {
         await accountRepository.VerifyPhoneNumber(model);
     }
 }
示例#5
0
 public async Task <ActionResult> SendPhoneNumber(VerifyPhoneNumberBindingModel model)
 {
     if (ModelState.IsValid)
     {
         await WebApiController.SendPhoneNumber(model);
     }
     return(View("Login"));
 }
示例#6
0
        public async Task <ActionResult> Verifyotp(VerifyPhoneNumberBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Error"));
            }
            await AccountApicontroller.Verifyotp(model);

            return(View("Signin"));
        }
示例#7
0
        public void CheckCodeAsync(string name)
        {
            VerifyPhoneNumberBindingModel model = new VerifyPhoneNumberBindingModel
            {
                Username = name
            };

            testmethodAsync(model);
            //  await AccountApicontroller.SendPhoneNumber(model);
        }
示例#8
0
        public async Task <ActionResult> VerifyPhoneNumber(VerifyPhoneNumberBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Error"));
            }
            await WebApiController.VerifyPhoneNumber(model);

            return(View("Login"));
        }
示例#9
0
        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");
        }
示例#10
0
 public async Task testmethodAsync(VerifyPhoneNumberBindingModel model)
 {
     await AccountApicontroller.SendPhoneNumber(model);
 }