Exemplo n.º 1
0
        public static string SendSmsCode(string mobile, string smsType = "all")
        {
            var code   = new Random(StaticSeed.Seed).Next(1000, 9999).ToString();
            var result = SMSUtil.SendSms(mobile, code);
            var key    = $"{mobile}-{smsType}-{code}";

            RedisCachedHelper.Set(key, code, false, 10);
            return(code);
        }
Exemplo n.º 2
0
        public static bool CheckSmsCode(string mobile, string code, string smsType = "all", bool removeKey = true)
        {
            var key   = $"{mobile}-{smsType}-{code}";
            var value = RedisCachedHelper.Get <string>(key);

            if (!string.IsNullOrEmpty(value) && removeKey)
            {
                RedisCachedHelper.RemoveKey(key);
            }
            return(!string.IsNullOrEmpty(value));
        }
Exemplo n.º 3
0
        public static bool RemoveSmsCodeCache(string mobile, string code, string smsType = "all")
        {
            var key = $"{mobile}-{smsType}-{code}";

            return(RedisCachedHelper.RemoveKey(key));
        }