Esempio n. 1
0
        public static string GetCode(string clientId)
        {
            Random         random = new Random();
            string         code   = random.Next(10231, 99999).ToString();
            CheckCodeParam param  = new CheckCodeParam();

            param.Code       = code;
            param.IsRequired = true;
            redisClient.SetString(clientId + "_code", JsonHelper.Serialize(param), TimeSpan.FromMinutes(5));
            return(code);
        }
Esempio n. 2
0
        public static bool IsRequired(string clientId)
        {
            string json = redisClient.GetString(clientId + "_code");

            if (string.IsNullOrEmpty(json))
            {
                return(false);
            }
            CheckCodeParam param = JsonHelper.Deserialize <CheckCodeParam>(json);

            return(param.IsRequired);
        }
Esempio n. 3
0
        public static bool Check(string clientId, string code)
        {
            string json = redisClient.GetString(clientId + "_code");

            if (string.IsNullOrEmpty(json))
            {
                return(true);
            }
            CheckCodeParam param = JsonHelper.Deserialize <CheckCodeParam>(json);

            return(param.Code == code);
        }