public async Task <ActionResult> SendOtpCode(SendOtpRequest model, CancellationToken ct) { var settings = await _responseSettingsStorage .Get(model.BusinessAcctId, model.AcctId, ct); if (settings == null) { await SaveOtpCode(model, 404, 0); return(NotFound()); } if (!SecretsAreEqual(settings.SharedSecret)) { await SaveOtpCode(model, 403, 0); return(StatusCode(403, "SharedSecret 'Authorization' header doesn't match the one configured")); } await SaveOtpCode(model, settings.StatusCode, settings.DelayMls); await Task .Delay(settings.DelayMls, ct); // send otp code here var customResult = GetCustomResult(settings.StatusCode); return(customResult ?? NoContent()); }
public async Task <IActionResult> SendOtp(int profileId, [FromBody] SendOtpRequest request) { var sendOtpCommand = new SendOtpCommand(profileId, request); var result = await mediator.Send(sendOtpCommand); return(StatusCode((int)result.Code, result.Value)); }
public SendOtpResponse SendOtp(SendOtpRequest payload) { var _client = new RestActions(_contentRootPath); string url = _configSettingManager.ArmBaseUrl + "/Otp/SendOtp"; var encryptedValue = new SecureCredentials(); payload.ServiceUsername = encryptedValue.DecryptCredentials(_configSettingManager.ArmServiceUsername); payload.ServicePassword = encryptedValue.DecryptCredentials(_configSettingManager.ArmServicePassword); return(_client.CallRestAction <SendOtpResponse, SendOtpRequest>(payload, url)); }
private async Task SaveOtpCode(SendOtpRequest model, int statusCode, int delay) { var entity = new OtpCodeEntity { SharedSecret = GetSharedSecretFromHeaders(), StatusCode = statusCode, DelayMls = delay, RequestJson = model.ToJson() }; await _otpCodeStorage .Insert(model.AcctId, entity, CancellationToken.None); }
/// <summary> /// Sends the otp. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> public async Task <APIResponse> SendOtp(ProfileIdDetails details, SendOtpRequest request) { try { var client = httpClientFactory.CreateClient(IdentityServiceOperation.serviceName); var param = JsonConvert.SerializeObject(request); HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json"); var response = await client.PostAsync(servicesConfig.Identity + IdentityServiceOperation.SendOtp(details.ProfileId), contentPost); return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'SendOtp()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }
public IActionResult AjaxSendOtp(string action) { var _user = new AuthenticateResponse { MembershipKey = 1006979, //1007435, EmailAddress = "*****@*****.**", //"*****@*****.**", FirstName = "Tolulope", LastName = "Olusakin", FullName = "Olusakin Tolulope S" //"Funmilayo Ruth Adeyemi", //MembershipKey = 1007435, //EmailAddress = "*****@*****.**", //FirstName = "Funmilayo", //LastName = "Adeyemi", //FullName = "Funmilayo Ruth Adeyemi", }; var _sessionID = "fb2e77d.47a0479900504cb3ab4a1f626d174d2d"; try { var OtpRequest = new SendOtpRequest { CustomerReference = _user.MembershipKey.ToString(), SessionId = _sessionID, CustomerAction = action }; var OtpResponse = _clientService.SendOtp(OtpRequest); return(Json(OtpResponse)); } catch (Exception ex) { TempData["message"] = ViewBag.Message = ex.Message; Utilities.ProcessError(ex, _contentRootPath); _logger.LogError(null, ex, ex.Message); } return(View()); }
public async Task <IActionResult> SendOtp(int profileId, [FromBody] SendOtpRequest request) { var result = await userService.SendOtp(new ProfileIdDetails(profileId), request); return(StatusCode((int)result.Code, result.Value)); }
/// <summary> /// Initializes a new instance of the <see cref="SendOtpCommand"/> class. /// </summary> /// <param name="profileId">The profile identifier.</param> /// <param name="request">The request.</param> public SendOtpCommand(int profileId, SendOtpRequest request) { Request = request; ProfileId = profileId; }