Пример #1
0
        private static TenantUserProfileBase MakeUser(int index)
        {
            var id = Guid.NewGuid();

            var model = new TenantUserProfileBase()
            {
                _id = id, UniqueUserId = $"{id}@ey.net"
            };

            if (index % 2 == 0)
            {
                model.Tenants.Add(Tenants[0]);
            }
            else
            {
                model.Tenants.Add(Tenants[1]);
            }

            foreach (var k in ConfigKeys)
            {
                model.SettingsPut(k, Faker.Lorem.Word());
            }

            return(model);
        }
Пример #2
0
        public static void BuildDemoData()
        {
            foreach (var t in Tenants)
            {
                var model = new TenantBase()
                {
                    _id     = t,
                    Contact = new ContactBase()
                    {
                        DisplayName = t.ToString(),
                        TenantId    = t,
                        ContactName = t.ToString()
                    },
                    Configuration = new List <KeyValuePair <string, string> >()
                    {
                        new KeyValuePair <string, string>("TenantDb", t.ToString())
                    }
                };
                Console.WriteLine(model.ToString());
                TenantProvider.TenantAddUpdate(model);
            }

            int ct = 0;

            foreach (var u in Usernames)
            {
                var model = new TenantUserProfileBase()
                {
                    UniqueUserId = u,
                    _id          = Guid.NewGuid(),
                };
                if (ct % 2 == 0)
                {
                    model.Tenants.Add(Tenants[0]);
                }
                else
                {
                    model.Tenants.Add(Tenants[1]);
                }

                model.SettingsPut("ct", ct.ToString());

                Console.WriteLine(model.ToString());

                UserProvider.Write(model);
                ct++;
            }
        }
Пример #3
0
        protected void Enrich(ref TenantUserProfileBase model)
        {
            if (model == null)
            {
                return;
            }

            foreach (var c in this.User.Claims)
            {
                var key   = c.Type;
                var index = key.LastIndexOf('/');
                if (index >= 0)
                {
                    key = key.Substring(index + 1);
                }
                var value = c.Value;
                if (okKeys.Contains(key))
                {
                    model.SettingsPut(key, value);
                }
            }
        }