public void LoadData() { var user = _security.AddUser("TestUser", "*****@*****.**", "SamePassword"); var apiKey = _security.AddApiKey(user); var url1 = _urlService.AddUrl("https://www.typescriptlang.org/docs/handbook/modules.html", user); var url2 = _urlService.AddUrl("https://habrahabr.ru/company/newprolab/blog/351616/", user); }
/// <summary> /// The save changes. /// </summary> /// <returns> /// The <see cref="Guid"/>. /// </returns> public Guid SaveChanges() { if (_user != null) { _user.Login = tbLogin.Text; _user.Email = tbEmail.Text; _user.Fio = tbFio.Text; // !!! не передавать внутрь функции пароль из tbPassword в режиме редактирования пользователя т.к. он там уже зашифрованный if (_user.Id == Guid.Empty) { _user.CreationDate = DateTime.Now; _user.LastLoginDate = DateTime.Now; _user.IsApproved = true; ////var hash = new PasswordHash(tbPassword.Text); ////string password = Convert.ToBase64String(hash.Hash); ////string salt = Convert.ToBase64String(hash.Salt); _user.Password = tbPassword.Text; ////_user.Salt = salt; return(_securityService.AddUser(_user).Id); } } return(_securityService.SaveUser(_user).Id); }
public UserDTO AddUser(UserDTO user) { var groupIdList = user.Groups.Select(p => new PartyId(p.PartyName)).ToList(); var workListUserIdList = user.WorkListPermittedUsers.Select(p => new PartyId(p.PartyName)).ToList(); var u = securityService.AddUser(new PartyId(user.PartyName), user.FirstName, user.LastName, user.Email, user.IsActive, user.CustomActions, groupIdList, workListUserIdList); return(userDTOMapper.MapToModel(u)); }
public async Task <IActionResult> AddUser([FromBody] UserDTO user) { Guard.Requires(user, nameof(user)).IsNotNull(); if (ModelState.IsValid) { return(Ok(await _securityService.AddUser(_mapper.Map <User>(user)))); } return(BadRequest(ModelState)); }
public ActionResult CreateUser(User model) { ValidationStateDictionary states = new ValidationStateDictionary(); model.UserRole = new Role() { RoleId = model.RoleId, RoleName = (from r in _securityService.GetRoleList() where r.RoleId == model.RoleId select r.RoleName).FirstOrDefault() }; model.InitiatedBy = ControllerContext.RequestContext.HttpContext.User.Identity.Name; if (model.AccountType == Constants.AccountType.LocalFinacle || model.AccountType == Constants.AccountType.ADLocal) { var flexcubeRecord = _flexCubeRepository.GetUserRoleFromFlexcube(model.Username); if (flexcubeRecord != null) { model.BranchID = flexcubeRecord.BranchCode; } } if (model.AccountType == Constants.AccountType.ADLocal && !string.IsNullOrEmpty(model.Username)) { if (!Access.IsUserInAD(model.Username)) { var errorMsg = "The user does not exist on AD or AD service could not be reached."; Danger(errorMsg, true); SetAuditInfo(errorMsg, string.Empty); return(View(model)); } } _securityService.AddUser(model, ref states); if (!states.IsValid) { model.UserRole = new Role() { RoleId = model.RoleId }; ModelState.AddModelErrors(states); var errorList = ValidationHelper.BuildModelErrorList(states); SetAuditInfo(Helper.StripHtml(errorList, true), string.Empty); return(View(model)); } else { Success(Constants.Messages.AddSuccessful, true); return(RedirectToAction("EditUser", new { id = model.Username })); } }
/// <summary> /// Добавляет пользователя /// </summary> /// <param name="user"> /// The user. /// </param> /// <returns> /// User /// </returns> public User AddUser(User user) { return(InvokeInterceptors(() => Service.AddUser(user))); }