Ejemplo n.º 1
0
 public GoogleImportService(GoogleClient google, CabinizerContext context, IHostEnvironment environment, ILogger <GoogleImportService> logger)
 {
     Google       = google;
     Context      = context;
     Logger       = logger;
     FileProvider = environment.ContentRootFileProvider;
 }
            private static async Task <string> GetOrgUnitPath(ICacheEntry entry, CabinizerContext context)
            {
                var userId = (string)entry.Key;

                var user = await context.Users
                           .Select(x => new { x.Id, OrgUnitPath = x.OrganizationUnitPath })
                           .SingleAsync(x => x.Id.Equals(userId));

                return(user.OrgUnitPath);
            }
            public async Task Invoke(HttpContext httpContext, CabinizerContext context)
            {
                if (httpContext.User.Identity.IsAuthenticated)
                {
                    var user = new CabinizerPrincipal(httpContext.User);

                    var orgUnitPath = await Cache.GetOrCreateAsync(user.Id, entry => GetOrgUnitPath(entry, context));

                    var identity = new ClaimsIdentity("Cabinizer");

                    identity.AddClaim(new Claim(CustomClaimTypes.OrgUnitPath, orgUnitPath));

                    httpContext.User.AddIdentity(identity);
                }

                await Next(httpContext);
            }
Ejemplo n.º 4
0
        private static async Task SeedData(CabinizerContext context, GoogleImportService google)
        {
            context.CurrentUser = CabinizerPrincipal.System;

            var rootOrgUnit = new OrganizationUnit
            {
                Path = Constants.RootOrganizationUnitPath,
                Name = "Miles",
            };

            await context.OrganizationUnits.AddAsync(rootOrgUnit);

            var systemUser = new User
            {
                Id                   = Constants.SystemUserId,
                GivenName            = "System",
                FamilyName           = "User",
                FullName             = "System User",
                PhoneNumber          = "+4712345678",
                Email                = "*****@*****.**",
                OrganizationUnitPath = Constants.RootOrganizationUnitPath,
            };

            await context.Users.AddAsync(systemUser);

            await google.ImportUsersAsync(CancellationToken.None);

            var cabin = new Item
            {
                Id = new Guid("01042e92-a3ca-46f7-85ba-0f223f97224a"),
                OrganizationUnitPath = "/",
                Name        = "Hytte, Tj�rhom Panorama",
                AdminUserId = Constants.SystemUserId,
            };

            await context.Items.AddAsync(cabin);

            await context.SaveChangesAsync();
        }
Ejemplo n.º 5
0
 public ItemController(CabinizerContext context)
 {
     Context = context;
 }
Ejemplo n.º 6
0
 public OrganizationUnitController(CabinizerContext context)
 {
     Context = context;
 }
Ejemplo n.º 7
0
 public UserController(CabinizerContext context, Cloudinary cloudinary)
 {
     Context    = context;
     Cloudinary = cloudinary;
 }