Ejemplo n.º 1
0
        private JObject CreateOTPData(OTPType otpType, string securityToken)
        {
            var     otp     = CommonUtility.RandomNumber(4);
            JObject otpData = new JObject();

            otpData[CommonConst.CommonField.ID]             = CommonUtility.GetNewID();
            otpData[CommonConst.CommonField.OTP]            = otp;
            otpData[CommonConst.CommonField.SECURITY_TOKEN] = securityToken;
            otpData[CommonConst.CommonField.OTP_TYPE]       = otpType.ToString();
            otpData[CommonConst.CommonField.DURATION]       = 15;
            otpData[CommonConst.CommonField.STATUS]         = OTPStatus.New.ToString();
            return(otpData);
        }
Ejemplo n.º 2
0
        public bool Validate(string phoneNumber, string otp, OTPType otpType, string securityToken = null)
        {
            Dictionary <string, string> filter = new Dictionary <string, string>();

            filter[CommonConst.CommonField.OTP]      = otp;
            filter[CommonConst.CommonField.PHONE]    = phoneNumber;
            filter[CommonConst.CommonField.STATUS]   = OTPStatus.New.ToString();
            filter[CommonConst.CommonField.OTP_TYPE] = otpType.ToString();

            var otpData = _dbService.FirstOrDefault(CommonConst.Collection.OTPs, filter);

            if (otpData != null)
            {
                otpData[CommonConst.CommonField.STATUS] = OTPStatus.Used.ToString();
                if (_dbService.Write(CommonConst.Collection.OTPs, otpData, filter))
                {
                    if (!string.IsNullOrEmpty(securityToken))
                    {
                        return(otpData[CommonConst.CommonField.SECURITY_TOKEN].ToString() == securityToken);
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    _logger.Error("Error updating OTP status on DB");
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        public string Now()
        {
            ProcessStartInfo start = new ProcessStartInfo();

            start.FileName               = PyPath;                                                                       //cmd is full path to python.exe
            start.Arguments              = $"GoogleAuthAPI/GoogleAuthPy/GoogleAuthPy.py {_t.ToString().ToLower()} {_s}"; //args is path to .py file and any cmd line args
            start.UseShellExecute        = false;
            start.RedirectStandardOutput = true;
            using (Process process = Process.Start(start))
            {
                using (StreamReader reader = process.StandardOutput)
                {
                    return(reader.ReadToEnd().Trim());
                }
            }
        }