コード例 #1
0
        public async Task <IActionResult> SendRegisterSMS(SendConfirmSMSRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var result = await _authService.SendConfirmSMS(model);

            return(Ok(result));
        }
コード例 #2
0
        public async Task <string> SendConfirmSMS(SendConfirmSMSRequest model)
        {
            var  random = new Random();
            var  code   = random.Next(100000, 999999).ToString();
            var  number = model.PhoneNumber.Replace(" ", "");
            User user   = await _userManager.Users.FirstOrDefaultAsync(user => user.PhoneNumber == number);

            if (!(user is null))
            {
                throw new AppExсeption(StatusCodes.Status400BadRequest, ExceptionConstant.UserAlreadyExist);
            }
            await _authMessageHelper.SendSmsAsync(number, $"Your Despatch verification code: { code } \n\n Thank you for choosing us. Best regards, Despatch team. \n\n { model.Hash }");


            return(code);
        }