public ActionResult CreateAccount(CreateAccountViewModel viewModel) { LocalAuthenticationController.RequireLocalAuthMode(); if (!ModelState.IsValid) { return(ViewCreateAccount(viewModel)); } var theSelectedOrganization = HttpRequestStorage.DatabaseEntities.Organizations.GetOrganization(viewModel.OrganizationID); Check.EnsureNotNull(theSelectedOrganization); var existingUser = HttpRequestStorage.DatabaseEntities.People.GetPersonByEmail(viewModel.Email, false); if (existingUser != null) { SetMessageForDisplay($"{existingUser.GetFullNameFirstLastAndOrgAsUrl(CurrentFirmaSession)} already has an account."); return(RedirectToAction(new SitkaRoute <UserController>(x => x.Detail(existingUser)))); } var newUser = CreateNewFirmaPersonWithoutKeystone(theSelectedOrganization, viewModel); HttpRequestStorage.DatabaseEntities.SaveChanges(); var saltAndHash = PBKDF2PasswordHash.CreateHash(viewModel.Password); var personLoginAccount = new PersonLoginAccount(newUser, newUser.Email, DateTime.Now, saltAndHash.PasswordHashed, saltAndHash.PasswordSalt, true, 0, 0); HttpRequestStorage.DatabaseEntities.AllPersonLoginAccounts.Add(personLoginAccount); HttpRequestStorage.DatabaseEntities.SaveChanges(); SetMessageForDisplay($"{newUser.GetFullNameFirstLastAndOrgAsUrl(CurrentFirmaSession)} successfully added. You may want to assign them a role."); return(RedirectToAction(new SitkaRoute <UserController>(x => x.Detail(newUser)))); }
public ActionResult CreateAccount() { LocalAuthenticationController.RequireLocalAuthMode(); var viewModel = new CreateAccountViewModel(); return(ViewCreateAccount(viewModel)); }
public PartialViewResult ChangePassword(PersonPrimaryKey personPrimaryKey) { LocalAuthenticationController.RequireLocalAuthMode(); var person = personPrimaryKey.EntityObject; var viewModel = new ChangePasswordViewModel(person); return(ViewChangePassword(viewModel, CurrentFirmaSession)); }
public PartialViewResult EditUser(PersonPrimaryKey personPrimaryKey) { LocalAuthenticationController.RequireLocalAuthMode(); var person = personPrimaryKey.EntityObject; var viewModel = new EditUserViewModel(person); return(ViewEditUser(viewModel)); }
public ActionResult EditUser(PersonPrimaryKey personPrimaryKey, EditUserViewModel viewModel) { LocalAuthenticationController.RequireLocalAuthMode(); var personBeingEdited = personPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewEditUser(viewModel)); } viewModel.UpdateModel(personBeingEdited, CurrentFirmaSession); return(new ModalDialogFormJsonResult()); }
public ActionResult ChangePassword(PersonPrimaryKey personPrimaryKey, ChangePasswordViewModel viewModel) { LocalAuthenticationController.RequireLocalAuthMode(); var personBeingEdited = personPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewChangePassword(viewModel, CurrentFirmaSession)); } var personAccount = personBeingEdited.PersonLoginAccount; var saltAndHash = PBKDF2PasswordHash.CreateHash(viewModel.NewPassword); personAccount.PasswordSalt = saltAndHash.PasswordSalt; personAccount.PasswordHash = saltAndHash.PasswordHashed; HttpRequestStorage.DatabaseEntities.SaveChanges(); SetMessageForDisplay($"{personBeingEdited.GetFullNameFirstLast()}'s password had been updated."); return(new ModalDialogFormJsonResult()); }