Beispiel #1
0
        public void SeedDatabase(KungFuContext ctx)
        {
            // Create two users with hashed and salted passwords
            string password  = "******";
            string password2 = "Yoda";

            var(passwordHashUser1, passwordSaltUser1) = _authentication.CreatePasswordHash(password);
            var(passwordHashUser2, passwordSaltUser2) = _authentication.CreatePasswordHash(password2);

            User user1 = new User()
            {
                Username     = "******",
                PasswordHash = passwordHashUser1,
                PasswordSalt = passwordSaltUser1,
                RefreshToken = null,
                IsAdmin      = true
            };

            User user2 = new User()
            {
                Username     = "******",
                PasswordHash = passwordHashUser2,
                PasswordSalt = passwordSaltUser2,
                RefreshToken = null,
                IsAdmin      = false
            };

            ctx.Users.Add(user1);
            ctx.Users.Add(user2);
            ctx.SaveChanges();
        }
Beispiel #2
0
        public void Seed(PetShopContext ctx)
        {
            string password = "******";

            byte[] passwordHashJoe, passwordSaltJoe, passwordHashAnn, passwordSaltAnn;
            authenticationHelper.CreatePasswordHash(password, out passwordHashJoe, out passwordSaltJoe);
            authenticationHelper.CreatePasswordHash(password, out passwordHashAnn, out passwordSaltAnn);

            List <User> users = new List <User>
            {
                new User {
                    Username     = "******",
                    PasswordHash = passwordHashJoe,
                    PasswordSalt = passwordSaltJoe,
                    IsAdmin      = false
                },
                new User {
                    Username     = "******",
                    PasswordHash = passwordHashAnn,
                    PasswordSalt = passwordSaltAnn,
                    IsAdmin      = true
                }
            };

            ctx.Users.AddRange(users);
            ctx.SaveChanges();
        }