public async Task <IActionResult> UserAdd() { var model = await _logonViewModelService.PrepareLogonModel(); model.Password = GeneratePassword.CreateRandomPassword(); return(View(model)); }
public AccountModel Create(AccountModel accountModel, IConfiguration configuration) { accountBusinessRules.CreateCheck(accountModel, unitOfWork.Account); accountModel.Password = GeneratePassword.CreateRandomPassword(); unitOfWork.Account.Insert(accountBuilder.Build(accountModel)); unitOfWork.Save(); SendCreateAccountEmail(accountModel, configuration); return(GetAccountByUsername(accountModel.Username)); }
public async Task <IActionResult> UserAdd(LogonModel model) { if (ModelState.IsValid) { var logonObj = _mapper.Map <Logon>(model); await _userService.InsertNewUser(logonObj); SuccessNotification("The user data has been saved successfully."); return(RedirectToAction("UserAdd")); } //If something failed redisplay form model = await _logonViewModelService.PrepareLogonModel(); model.Password = GeneratePassword.CreateRandomPassword(); return(View(model)); }
public async Task <ActionResult> CreateUser(IPLBidder iplBidder) { iplBidder.password = GeneratePassword.CreateRandomPassword(8); iplBidder.roleID = (int)UserRoles.Bidder; int success = userDB.createUser(iplBidder, 1); if (success == 1) { // Task.Run(async () => SendEmail(iplBidder)); return(Json(new { data = new Result { Status = ResultStatus.Success, Message = "User registered successfully." } }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { data = new Result { Status = ResultStatus.Error, Message = "Error occurred while registering user." } }, JsonRequestBehavior.AllowGet)); } }
public void ValidCreateUserTest() { SecurityUserDto securityUser = new SecurityUserDto() { Title = "Mr", FirstName = "Qinisela", LastName = "Molefe", Initials = "Q E", UserName = GeneratePassword.CreateRandomPassword(), PasswordSalt = GeneratePassword.PasswordSalt(), IDNumber = "8707255584080", CrudOperation = CrudOperations.Create }; securityUser.Password = GeneratePassword.HashedPassword("password1", securityUser.PasswordSalt); Response <SecurityUserDto> response = _PhekoServiceClient.SaveUser(securityUser); Assert.IsFalse(response.HasErrors); Assert.IsTrue(response.FieldErrors.Count == 0); Assert.IsNotNull(response.Model); }
public Response <SecurityUserDto> ResetPassword(string username) { Response <SecurityUserDto> response = _SecurityUserBusinessRules.ResetPasswordCheck(username); if (response.HasErrors) { return(response); } using (UnitOfWork unitOfWork = new UnitOfWork()) { SecurityUser securityUser = unitOfWork.SecurityUserRepository.GetEntities(s => s.UserName.ToLower() == username.ToLower(), null, "SecurityUserRoles").FirstOrDefault <SecurityUser>(); if (securityUser == null) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { FieldName = "Username", ErrorMessage = "Incorrect username." }); return(response); } string newPassword = GeneratePassword.CreateRandomPassword(); byte[] newhashedPassword = GeneratePassword.HashedPassword(newPassword, securityUser.PasswordSalt); securityUser.Password = newhashedPassword; securityUser.FirstTimeLogInInd = true; unitOfWork.SecurityUserRepository.Update(securityUser); unitOfWork.Save(); response.Model = _SecurityUserMapper.MapToSecurityUserDto(securityUser); } return(response); }