private void SaveNewContentToDb(string content, string contentId, ItemToProcess itemToProcess) { //Save the Id in the data base and start the processing of new item async _comparisonService.CreateNewComparison(contentId); new Thread(() => { itemToProcess.Hash = _hashService.CreateHash(content); _comparisonService.CreateNewComparison(contentId); _itemToProcessRepository.SaveDataToDB(itemToProcess); _comparisonService.UpdateComparisonToProcessing(contentId, StatusEnum.PROCESSED_FIRST); }).Start(); }
private OrderSessionsDto GetOrderSessionsDto(SessionInfo sessionInfo) => new OrderSessionsDto { Id = 0, CardNumber = hashService.CreateHash(sessionInfo.CardNumber), SessionId = sessionInfo.SessionId };
public async Task <IResult> AddAsync(User user) { user.Password = _hashService.CreateHash(user.Password); var validationResult = _userValidator.Validate(user); if (!validationResult.IsValid) { var firstErrorMessage = validationResult.Errors.Select(failure => failure.ErrorMessage).FirstOrDefault(); return(new ErrorResult(firstErrorMessage)); } await _userDal.AddAsnyc(user); return(new SuccessResult(ResultMessages.UserAdded)); }
public void Create(string firstName, string lastName, string email, string password) { var university = _universityRepository.Table.FirstOrDefault(x => x.UniversityMailExtension == email.Split('@', StringSplitOptions.None)[1]); if (university == null) { throw new InvalidStudentMailException(); } if (_userRepository.Table.Any(x => x.UserEmail == email)) { throw new EmailIsTakenException(); } _hashService.CreateHash(password, out var passwordHash, out var passwordSalt); var verificationHash = Guid.NewGuid().ToString(); var user = new UserEntity { UserFirstName = firstName, UserLastName = lastName, UserEmail = email, UserUniversityIdFk = university.UniversityIdPk, UserPasswordHash = passwordHash, UserPasswordSalt = passwordSalt }; _userRepository.Insert(user); _userRepository.SaveAll(); _verificationRepository.Insert(new VerificationEntity { VerificationUserIdFk = user.UserIdPk, VerificationHash = verificationHash, VerificationType = VerificationType.Email }); _verificationRepository.SaveAll(); _emailService.SendVerificationEmail(email, verificationHash); }
public int RegisterUser(NewUser newUser) { if (string.IsNullOrEmpty(newUser.EmailAddress)) { throw new ArgumentNullException(nameof(newUser.EmailAddress)); } if (string.IsNullOrEmpty(newUser.Password)) { throw new ArgumentNullException(nameof(newUser.Password)); } var existingUser = GetUser(newUser.EmailAddress); if (existingUser != null) { throw new Exception($"A user with email address {newUser.EmailAddress} already exists."); } using (var db = new LiteDatabase(dbLocation)) { var salt = hashService.CreateSalt(); var user = new User { EmailAddress = newUser.EmailAddress, Name = newUser.Name, CreateDateTime = DateTime.Now, PasswordSalt = salt, PasswordHash = hashService.CreateHash(newUser.Password, salt) }; var userCollection = db.GetCollection <User>("users"); userCollection.EnsureIndex(u => u.Id); var userId = userCollection.Insert(user); return(userId.AsInt32); } }
public void UpdatePassword(string newPassword, string passwordResetEntryKey) { var passwordLink = _passwordResetService.GetPasswordLink(passwordResetEntryKey); if (!_passwordResetService.IsKeyValid(passwordLink)) { throw new ApplicationException("Password key is invalid"); } var user = passwordLink.User; user.Password = _hashService.CreateHash(newPassword); var userDto = Mapper.Map <UserDto>(user); _userService.Update(user.Id, password: user.Password); _passwordResetService.UpdateLinkActivatedDate(passwordLink); }
/// <summary> /// Ключ для валидации уведомления - хэш от проданного ключа и прибыли продавца /// </summary> private string GetValidationKey(OrderInfo order, Earnings earnings) => hashService.CreateHash(new string[] { order.Key, earnings.Income.ToString() });
public User RegisterUser(User user, int userTypeId) { user.Password = _hashService.CreateHash(user.Password); return(AddUser(user, userTypeId)); }