Example #1
0
        private static void ChangePassword(DbContext context, User user, string newPassword)
        {
            byte[] salt;

            user.PasswordHash = HashPasswordGeneratingSalt(newPassword, out salt);
            user.PasswordSalt = salt;

            context.SaveChanges();
        }
Example #2
0
        public static void CreateUser(DbContext context, string username, string password, string emailAddress, string firstName, string lastName, bool isAdmin)
        {
            User user = new User();

            user.ID = username;
            user.FirstName = firstName;
            user.LastName = lastName;
            user.EmailAddress = emailAddress;
            user.CreatedDate = DateTime.UtcNow;
            user.LastUpdatedDate = DateTime.UtcNow;
            user.IsAdmin = isAdmin;

            byte[] salt;

            user.PasswordHash = HashPasswordGeneratingSalt(password, out salt);
            user.PasswordSalt = salt;

            context.Users.Add(user);
        }