public PasswordSoultModel GetPasswordHashSoult(string modelPassword) { using (var hmac = new HMACSHA512()) { PasswordSoultModel passeordSoult = new PasswordSoultModel() { PasswordHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(modelPassword)), PasswordSalt = hmac.Key }; return(passeordSoult); } }
public Task <User> ArrangeNewUser(RegisterDto registerDto, PasswordSoultModel passwordSoultModel) { throw new NotImplementedException(); }
public async Task <User> ArrangeNewUser(RegisterDto registerDto, PasswordSoultModel passwordSoultModel) { var contactDetailsId = Guid.NewGuid(); var eMailId = Guid.NewGuid(); var phoneId = Guid.NewGuid(); var cityId = (await _cityService.FindCityByName(registerDto.City)).Id; var countryId = (await _countryService.FindCountryByName(registerDto.Country)).Id; EMail mail = new EMail() { Id = eMailId, UserEMail = registerDto.Email, CreateDate = DateTime.Now, ContactDetailsId = contactDetailsId }; Phone phone = new Phone() { Id = phoneId, PhoneNumber = registerDto.Phones, CreateDate = DateTime.Now, ContactDetailsId = contactDetailsId }; List <EMail> emList = new List <EMail>() { mail }; List <Phone> phoneList = new List <Phone>() { phone }; try { var newUser = new User() { Id = Guid.NewGuid(), Login = registerDto.Login, LastName = registerDto.LastName, PasswordHash = passwordSoultModel.PasswordHash, PasswordSalt = passwordSoultModel.PasswordSalt, ContactDetailsId = contactDetailsId, ContactDetails = new ContactDetails() { Id = contactDetailsId, CountryId = countryId, CityId = cityId, EMails = emList, Phones = phoneList }, RoleId = (await _roleService.GetRoleIdyByName("User")).Id, DayOfBirth = registerDto.DayOfBirth }; return(newUser); } catch (Exception ex) { Log.Error($"Can't create user. Details: {ex.Message}"); } return(new User()); }