Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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));
            }
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 8
0
 /// <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;
 }