Esempio n. 1
0
        public string Init()
        {
            _loginService.Register(
                new Model.DTO.UserInfoDTO.LoginPassword()
            {
                Login    = "******",
                Password = "******"
            },
                Constants.RoleNames.Admin);
            _adminRepository.Create(new Admin()
            {
                FIO   = "DimaK",
                Login = "******"
            });
            _userLoginInfoRepository.SaveChanges();
            _loginService.Register(
                new Model.DTO.UserInfoDTO.LoginPassword()
            {
                Login    = "******",
                Password = "******"
            },
                Constants.RoleNames.Integrator);
            var ug = _userGroupRepository.Create(new UserGroup()
            {
                Name = "test1",
            });

            _userRepository.Create(new User()
            {
                Login       = "******",
                UserGroupId = ug.Id,
                UserType    = UserType.Integrator
            });
            var sc = _scenarioRepository.CreateScenario(new Scenario()
            {
                Author      = "DimaIntegr",
                Description = "test",
                Name        = "test",
                Publicity   = false,
                Script      = "TestScript",
                Type        = 1,
                UserGroupId = ug.Id
            });
            var ct = _controllerRepository.CreateController(new SmartController()
            {
                Adress      = "http://localhost:5000/api",
                Description = "test",
                Name        = "test",
                Password    = "******",
                Type        = 1,
                UserGroupId = ug.Id
            });
            var list = new List <KeyValuePair <long, bool> >();

            list.Add(new KeyValuePair <long, bool>(sc.Id, true)
                     );
            _connections.Set(list, ct.Id);
            _userGroupRepository.SaveChanges();
            return(ct.Id.ToString() + " " + sc.Id.ToString());
        }
Esempio n. 2
0
        public void ChangePassword(LoginPassword input)
        {
            var info = _userLoginInfoRepository[input.Login];

            byte[] salt = new byte[128 / 8];
            using (var rng = RandomNumberGenerator.Create())
            {
                rng.GetBytes(salt);
            }

            // derive a 256-bit subkey (use HMACSHA1 with 10,000 iterations)
            string hashed = Convert.ToBase64String(KeyDerivation.Pbkdf2(
                                                       password: input.Password,
                                                       salt: salt,
                                                       prf: KeyDerivationPrf.HMACSHA1,
                                                       iterationCount: 10000,
                                                       numBytesRequested: 256 / 8));

            info.HashedPassword = hashed;
            info.Salt           = salt;
            _userLoginInfoRepository.SaveChanges();
        }