예제 #1
0
        public User GenerateUser()
        {
            string username = GenerateUniqueUserName();

            return(new User
            {
                Id = DataUtil.GenerateUniqueId(),
                Username = username,
                NormalizedUserName = username.ToUpper(),
                Domain = string.Empty,
                PasswordHash = "AQAAAAEAACcQAAAAEBhhMYTL5kwYqXheHSdarA/+vleSI07yGkTKNw1bb1jrTlYnBZK1CZ+zdHnqWwLLDA==",
                Email = username + "@portal.com",
                NormalizedEmail = username.ToUpper() + "@PORTAL.COM",
                IsConfirmedEmail = true,
                SecurityStamp = "7YHYVBYWLTYC4EAPVRS2SWX2IIUOZ3XM",
                AccessFailedCount = 0,
                IsLockoutEnabled = false,
                LockoutEndDate = DateTime.UtcNow,
                Roles = new List <string>
                {
                    "SuperAdmin"
                },
                Claims = new List <BaseClaim>
                {
                    StandardClaims.AccessAppSelectorPage,
                    StandardClaims.Sub("5ce287ee569d6f23e8504cef"),
                    StandardClaims.UserId("5ce287ee569d6f23e8504cef"),
                    StandardClaims.Name(username)
                }
            });
        }
예제 #2
0
        private void CreateSomeDummyData()
        {
            MongoClient             mongoClient    = new MongoClient(MongoDatabaseOptions.ConnectionString);
            IMongoDatabase          mongoDatabase  = mongoClient.GetDatabase(MongoDatabaseOptions.Datasource);
            IMongoCollection <Role> roleCollection = mongoDatabase.GetCollection <Role>("roles");
            IMongoCollection <User> userCollection = mongoDatabase.GetCollection <User>("users");
            Role superAdminRole = new Role
            {
                Id             = "5c06a15e4cc9a850bca44488",
                Name           = "SuperAdmin",
                NormalizedName = "SUPERADMIN",
                DisplayName    = "Super Admin",
                Claims         = new List <BaseClaim>
                {
                    StandardClaims.AccessCoreApp("5c162e9005924c1c741bfdc2")
                }
            };

            // Pass: @Dm1n!
            User adminAccount = new User
            {
                Id                 = "5ce287ee569d6f23e8504cef",
                Username           = "******",
                NormalizedUserName = "******",
                Domain             = string.Empty,
                PasswordHash       = "AQAAAAEAACcQAAAAEBhhMYTL5kwYqXheHSdarA/+vleSI07yGkTKNw1bb1jrTlYnBZK1CZ+zdHnqWwLLDA==",
                Email              = "*****@*****.**",
                NormalizedEmail    = "*****@*****.**",
                IsConfirmedEmail   = true,
                SecurityStamp      = "7YHYVBYWLTYC4EAPVRS2SWX2IIUOZ3XM",
                AccessFailedCount  = 0,
                IsLockoutEnabled   = false,
                LockoutEndDate     = DateTime.UtcNow,
                Roles              = new List <string>
                {
                    "SuperAdmin"
                },
                Claims = new List <BaseClaim>
                {
                    StandardClaims.AccessAppSelectorPage,
                    StandardClaims.Sub("5ce287ee569d6f23e8504cef"),
                    StandardClaims.UserId("5ce287ee569d6f23e8504cef"),
                    StandardClaims.Name("admin")
                }
            };

            roleCollection.InsertOne(superAdminRole);
            userCollection.InsertOne(adminAccount);
        }