public JObject RegisterMobile() { try { var request = _httpContextProxy.GetRequestBody <MobileAuthRegisterRequest>(); request.device_address = _httpContextProxy.GetHeader("device_address"); request.app_version = _httpContextProxy.GetHeader("app_version"); request.x_auth_token = _httpContextProxy.GetHeader("x_auth_token"); var results = new Dictionary <string, string>(); if (request.IsValidModel(out results)) { // TO DO : Send mobile validation OTP MobileAuthRegisterResponse mobileAuthRegisterResponse = _ZNxtUserService.RegisterMobile(request); if (mobileAuthRegisterResponse.code == CommonConst._1_SUCCESS) { if (_userNotifierService.SendMobileAuthRegistrationOTPAsync(mobileAuthRegisterResponse).GetAwaiter().GetResult() || MOBILE_AUTH_IGNORE_OTP_VALIDATION) { return(_responseBuilder.Success(null, mobileAuthRegisterResponse.ToJObject())); } else { return(_responseBuilder.ServerError("Error sending SMS OTP")); } } else { return(_responseBuilder.CreateReponseWithError(mobileAuthRegisterResponse.code, mobileAuthRegisterResponse.errors)); } } else { _logger.Debug("Model validation fail"); JObject errors = new JObject(); foreach (var error in results) { errors[error.Key] = error.Value; } return(_responseBuilder.BadRequest(errors)); } } catch (Exception ex) { _logger.Error(ex.Message, ex); return(_responseBuilder.ServerError()); } }
public async Task <bool> SendMobileAuthRegistrationOTPAsync(MobileAuthRegisterResponse mobileAuth, string message = null) { try { var mobileNo = mobileAuth.mobile_number; var otpReqeust = new JObject() { ["To"] = mobileNo, ["Message"] = "Account Activation OTP is {{OTP}} ", ["Type"] = "SMS", ["OTPType"] = "mobile_auth_activation", ["SecurityToken"] = mobileAuth.validation_token, ["message"] = message }; var result = await _apiGatewayService.CallAsync(CommonConst.ActionMethods.POST, "/notifier/otp/send", null, otpReqeust); return(result["code"].ToString() == "1"); } catch (Exception ex) { _logger.Error($"Error sending mobile_auth_registration to {mobileAuth.mobile_number}. Error:{ex.Message}", ex); return(false); } }
public Task <bool> SendMobileAuthRegistrationOTPAsync(MobileAuthRegisterResponse mobileAuth, string message = null) { return(Task.FromResult(true)); }