示例#1
0
 public UserPlatformRoleAccessor(IPlatformUser user, IUserRoleService userRole, IPlatformFunctionService functionService, IMemoryCache cache)
 {
     if (user != null)
     {
         var key = Core.CacheKeyBuilder.UserRole(user.Id);
         roles = cache.GetOrCreate(key, entry =>
         {
             entry.AbsoluteExpirationRelativeToNow = new System.TimeSpan(0, 10, 0);
             var roleCodes = userRole.GetRoleCodes(user).Result;
             return(functionService.Functions.SelectMany(x => x.Permissions).Where(x => roleCodes.Contains(x.Code)).ToArray());
         });
     }
 }
 public PlatformFunctionController(IPlatformFunctionService functionService)
 {
     this.functionService = functionService;
 }
 public ConsoleController(Hcs.Platform.Data.PlatformDbContext dbContext, IPasswordHashService passwordHashService, IPlatformFunctionService functionService)
 {
     this.functionService     = functionService;
     this.passwordHashService = passwordHashService;
     this.dbContext           = dbContext;
 }