Example #1
0
 public void Clear(long userId)
 {
     UserDataChangeTime.Update(userId, DateTime.UtcNow);
     foreach (var k in CacheKeyBuilder.GetAllKeys(userId))
     {
         cache.Remove(k);
     }
 }
        private static bool ValidateTokenLifeTime(DateTime?notBefore, DateTime?expires, SecurityToken securityToken, TokenValidationParameters validationParameters)
        {
            if (!notBefore.HasValue || string.IsNullOrWhiteSpace(securityToken.Id))
            {
                return(false);
            }
            var now = DateTime.UtcNow;

            if (notBefore.Value <= now && (!expires.HasValue || (expires.HasValue && expires.Value >= now)))
            {
                if (UserDataChangeTime.Get(long.Parse(securityToken.Id)) <= notBefore.Value)
                {
                    return(true);
                }
            }
            return(false);
        }
 private static void DbInit(IApplicationBuilder app)
 {
     using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
     {
         using (var context = serviceScope.ServiceProvider.GetRequiredService <PlatformDbContext>())
         {
             context.Database.EnsureCreated();
             var flags = context.Set <Hcs.Platform.BaseModels.PlatformFlag>();
             if (!flags.Any(x => x.Flag == "SeedData" && x.Value == "true"))
             {
                 flags.Add(new Hcs.Platform.BaseModels.PlatformFlag {
                     Flag = "SeedData", Value = "true"
                 });
                 context.SaveChanges();
                 DbContextBuilder.RunSeeds(context);
             }
             foreach (var u in context.Set <Hcs.Platform.BaseModels.PlatformUser>())
             {
                 UserDataChangeTime.Update(u.Id, u.LastUpdatedTime ?? DateTime.MinValue);
             }
         }
     }
 }