Exemplo n.º 1
0
 public async Task <string> TokenAsync(string phone, string password)
 {
     return(await _cache.GetOrCreateAsync(TicksToken + DateTime.Now.ToString("yyyyMMdd") + phone, async entry =>
     {
         entry.SlidingExpiration = TimeSpan.FromHours(12);
         var user = await _queries.GetModelAsync(phone);
         if (user == null)
         {
             throw new EPTException($"不存在手机号为为:{phone}的用户");
         }
         else
         {
             if (user.Password != password)
             {
                 throw new EPTException($"密码不正确");
             }
             else
             {
                 string keyvalue = DESEncryptHelper.Encrypt(phone, DateTime.Now.ToString("yyyyMMdd"));
                 return keyvalue;
             }
         }
     }));
 }