private PartialViewResult ViewActivateInactivatePerson(Person person, ConfirmDialogFormViewModel viewModel) { string confirmMessage; if (person.IsActive) { // Now allowed, but we warn the user : PF-2308 - https://sitkatech.atlassian.net/secure/RapidBoard.jspa?rapidView=39&projectKey=PF&modal=detail&selectedIssue=PF-2308 const bool confirmDialogCanProceed = true; string optionalOrganizationPrimaryContactWarnings = string.Empty; bool isPrimaryContactForAnyOrganization = person.OrganizationsWhereYouAreThePrimaryContactPerson.Any(); if (isPrimaryContactForAnyOrganization) { optionalOrganizationPrimaryContactWarnings = $@"{person.GetFullNameFirstLast()} is the {FieldDefinitionEnum.OrganizationPrimaryContact.ToType().GetFieldDefinitionLabel()} for the following organizations: <ul> {string.Join("\r\n", person.GetPrimaryContactOrganizations().Select(x => $"<li>{x.OrganizationName}</li>"))}</ul>"; } confirmMessage = $"{optionalOrganizationPrimaryContactWarnings}Are you sure you want to inactivate user '{person.GetFullNameFirstLast()}'?"; var viewData = new ConfirmDialogFormViewData(confirmMessage, confirmDialogCanProceed); return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>( viewData, viewModel)); } else { confirmMessage = $"Are you sure you want to activate user '{person.GetFullNameFirstLast()}'?"; var viewData = new ConfirmDialogFormViewData(confirmMessage, true); return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>( viewData, viewModel)); } }
private void ShowWarningAboutInactivatedUserForOrganizationPrimaryContact(Person person) { bool inactivePersonWhoIsOrgPrimaryContact = !person.IsActive && person.OrganizationsWhereYouAreThePrimaryContactPerson.Any(); if (inactivePersonWhoIsOrgPrimaryContact) { SetWarningForDisplay($"{person.GetFullNameFirstLast()} is the {FieldDefinitionEnum.OrganizationPrimaryContact.ToType().GetFieldDefinitionLabel()} for one or more {FieldDefinitionEnum.Organization.ToType().GetFieldDefinitionLabelPluralized()}. {person.GetFullNameFirstLast()} has been inactivated, but the {FieldDefinitionEnum.Organization.ToType().GetFieldDefinitionLabelPluralized()} {FieldDefinitionEnum.OrganizationPrimaryContact.ToType().GetFieldDefinitionLabel()}(s) need to be changed."); } }
private static void SendExistingKeystoneUserCreatedMessage(Person person, Person currentPerson) { var toolDisplayName = MultiTenantHelpers.GetToolDisplayName(); var subject = $"Invitation to {toolDisplayName}"; var message = $@" <div style='font-size: 12px; font-family: Arial'> Welcome {person.FirstName}, <p> You have been invited by a colleague, {currentPerson.GetFullNameFirstLast()}, to check out <a href=""{SitkaRoute<HomeController>.BuildAbsoluteUrlHttpsFromExpression(x => x.Index())}\"">{toolDisplayName}</a>. </p> <p> Because you have logged into other systems that use the same log in service (Keystone) that {toolDisplayName} uses, you already have an account, but it needs to be activated for {toolDisplayName}. </p> <p> When you have a moment, please activate your account by logging in: </p> <strong>Log in here:</strong> <a href=""{FirmaHelpers.GenerateAbsoluteLogInUrl()}"">{toolDisplayName}</a><br /> <strong>Your user name is:</strong> {person.LoginName}<br /> <p> If you don't remember your password, you will be able to reset it from the link above. </p> <p> Sincerely,<br /> The {toolDisplayName} team<br/><br/><img src=""cid:tool-logo"" width=""160"" /> </p>"; var mailMessage = new MailMessage { From = new MailAddress(FirmaWebConfiguration.DoNotReplyEmail), Subject = subject, Body = message, IsBodyHtml = true }; var tenantAttribute = MultiTenantHelpers.GetTenantAttributeFromCache(); var toolLogo = tenantAttribute.TenantSquareLogoFileResourceInfo ?? tenantAttribute.TenantBannerLogoFileResourceInfo; var htmlView = AlternateView.CreateAlternateViewFromString(message, null, "text/html"); htmlView.LinkedResources.Add( new LinkedResource(new MemoryStream(toolLogo.FileResourceData.Data), "img/jpeg") { ContentId = "tool-logo" }); mailMessage.AlternateViews.Add(htmlView); mailMessage.ReplyToList.Add(currentPerson.Email); mailMessage.To.Add(person.Email); SitkaSmtpClient.Send(mailMessage); }
public void ImpersonateUser(Person personToImpersonate, Uri optionalPreviousPageUri, out string impersonationStatusMessage, out string impersonationStatusWarning) { Check.EnsureNotNull(this.PersonID, "Anonymous users can't impersonate authentic users."); Check.EnsureNotNull(personToImpersonate, "You can't impersonate an Anonymous user."); impersonationStatusWarning = null; string currentImpersonationString = string.Empty; // Keep track of who we started as -- unless we are *already* impersonating, // in which case we keep our original identity through each new impersonation. if (OriginalPerson == null) { OriginalPerson = Person; } else { // If we are trying to impersonate *ourself*, we instead resume our original session. // (there are other checks elsewhere to prevent and warn about this, but this is a last-ditch exit.) if (OriginalPerson.PersonID == personToImpersonate.PersonID) { ResumeOriginalUser(optionalPreviousPageUri, out impersonationStatusMessage); return; } currentImpersonationString = $" (currently impersonating {Person.GetFullNameFirstLast()})"; } var lastPageLinkHtml = MakeLastPageLinkHtml(optionalPreviousPageUri); // Switch to the new user we want to impersonate Person = personToImpersonate; impersonationStatusMessage = $"Logon {OriginalPerson.GetFullNameFirstLast()}{currentImpersonationString} switching to impersonate Logon {personToImpersonate.GetFullNameFirstLast()}.{lastPageLinkHtml}"; //_logger.InfoFormat(impersonationStatusMessage); if (!personToImpersonate.IsActive) { impersonationStatusWarning = $"Logon {personToImpersonate.GetFullNameFirstLast()} is inactive. Impersonation will allow you to act as this person, but be aware of potential issues due to the account being inactive."; } }
private static void SendExistingKeystoneUserCreatedMessage(Person person, Person currentPerson) { var toolDisplayName = MultiTenantHelpers.GetToolDisplayName(); var subject = $"Invitation to {toolDisplayName}"; var message = $@" <div style='font-size: 12px; font-family: Arial'> Welcome {person.FirstName}, <p> You have been invited by a colleague, {currentPerson.GetFullNameFirstLast()}, to check out <a href=""{SitkaRoute<HomeController>.BuildAbsoluteUrlHttpsFromExpression(x => x.Index())}\"">{toolDisplayName}</a>. </p> <p> Because you have logged into other systems that use the same log in service (Keystone) that {toolDisplayName} uses, you already have an account, but it needs to be activated for {toolDisplayName}. </p> <p> When you have a moment, please activate your account by logging in: </p> <strong>Log in here:</strong> <a href=""{FirmaHelpers.GenerateAbsoluteLogInUrl()}"">{toolDisplayName}</a><br /> <strong>Your user name is:</strong> {person.LoginName}<br /> <p> If you don't remember your password, you will be able to reset it from the link above. </p> <p> Sincerely,<br /> The {toolDisplayName} team </p>"; var mailMessage = new MailMessage { From = new MailAddress(FirmaWebConfiguration.DoNotReplyEmail), Subject = subject, Body = message, IsBodyHtml = true }; mailMessage.ReplyToList.Add(currentPerson.Email); mailMessage.To.Add(person.Email); SitkaSmtpClient.Send(mailMessage); }
public void ResumeOriginalUser(Uri optionalPreviousPageUri, out string impersonationStatusMessage) { var lastPageLinkHtml = MakeLastPageLinkHtml(optionalPreviousPageUri); Check.EnsureNotNull(OriginalPerson, "FirmaSession {0} is not impersonating; it is not valid to call ResumeOriginalUser()"); impersonationStatusMessage = $"Logon {OriginalPerson.GetFullNameFirstLast()} resuming their original session; ceasing impersonation of Logon {Person.GetFullNameFirstLast()}.{lastPageLinkHtml}"; //_logger.InfoFormat(impersonationStatusMessage); // Swap back Person = OriginalPerson; // Clear impersonation data OriginalPerson = null; OriginalPersonID = null; }