protected override Action getPageViewDataModificationMethod() { pageViewDataModificationsExecuted = true; if (!info.User.Any()) { return(null); } return(() => UserImpersonationStatics.BeginImpersonation(info.UserObject)); }
protected override void loadData() { BasicPage.Instance.Body.Attributes["class"] = CssElementCreator.SelectUserPageBodyCssClass; ph.AddControlsReturnThis(new PageName()); if (AppTools.IsLiveInstallation) { ph.AddControlsReturnThis( new Paragraph( new Strong("Warning:"), " Do not impersonate a user without permission. Your actions will be attributed to the user you are impersonating, not to you.".GetLiteralControl())); } var pb = PostBack.CreateFull( actionGetter: () => new PostBackAction(new ExternalResourceInfo(info.ReturnUrl.Any() ? info.ReturnUrl : NetTools.HomeUrl))); DataValue <User> user = new DataValue <User>(); ph.AddControlsReturnThis( FormItem.Create( "User's email address (leave blank for anonymous)", new EwfTextBox(""), validationGetter: control => new EwfValidation( (pbv, validator) => { var errorHandler = new ValidationErrorHandler("user"); var emailAddress = validator.GetEmailAddress(errorHandler, control.GetPostBackValue(pbv), true); if (errorHandler.LastResult != ErrorCondition.NoError) { return; } if (!emailAddress.Any()) { user.Value = null; return; } user.Value = UserManagementStatics.GetUser(emailAddress); if (user.Value == null) { validator.NoteErrorAndAddMessage("The email address you entered does not match a user."); } }, pb)).ToControl(), new Paragraph( new PostBackButton( pb, new ButtonActionControlStyle( AppRequestState.Instance.ImpersonatorExists ? "Change User" : "Begin Impersonation", buttonSize: ButtonActionControlStyle.ButtonSize.Large)))); pb.AddModificationMethod(() => UserImpersonationStatics.BeginImpersonation(user.Value)); }
protected override void loadData() { if (info.User.Any()) { if (!pageViewDataModificationsExecuted) { throw new ApplicationException("Page-view data modifications did not execute."); } ph.AddControlsReturnThis(new Paragraph("Please wait.".ToComponents()).ToCollection().GetControls()); StandardLibrarySessionState.Instance.SetInstantClientSideNavigation(new ExternalResourceInfo(info.ReturnUrl).GetUrl()); return; } BasicPage.Instance.Body.Attributes["class"] = CssElementCreator.SelectUserPageBodyCssClass; ph.AddControlsReturnThis(new PageName().ToCollection().GetControls()); if (ConfigurationStatics.IsLiveInstallation) { ph.AddControlsReturnThis( new Paragraph( new ImportantContent("Warning:".ToComponents()).ToCollection() .Concat( " Do not impersonate a user without permission. Your actions will be attributed to the user you are impersonating, not to you." .ToComponents()) .Materialize()).ToCollection() .GetControls()); } var user = new DataValue <User>(); var pb = PostBack.CreateFull( firstModificationMethod: () => UserImpersonationStatics.BeginImpersonation(user.Value), actionGetter: () => new PostBackAction(new ExternalResourceInfo(info.ReturnUrl.Any() ? info.ReturnUrl : NetTools.HomeUrl))); FormState.ExecuteWithDataModificationsAndDefaultAction( pb.ToCollection(), () => { ph.AddControlsReturnThis( new EmailAddressControl( "", true, validationMethod: (postBackValue, validator) => { if (!postBackValue.Any()) { user.Value = null; return; } user.Value = UserManagementStatics.GetUser(postBackValue); if (user.Value == null) { validator.NoteErrorAndAddMessage("The email address you entered does not match a user."); } }).ToFormItem(label: "User's email address (leave blank for anonymous)".ToComponents()) .ToComponentCollection() .Append( new Paragraph( new EwfButton( new StandardButtonStyle( AppRequestState.Instance.ImpersonatorExists ? "Change User" : "Begin Impersonation", buttonSize: ButtonSize.Large)) .ToCollection())) .GetControls()); }); }
protected override PageContent getContent() { if (User.Any()) { return(new BasicPageContent( bodyClasses: elementClass, pageLoadPostBack: PostBack.CreateFull( modificationMethod: () => UserImpersonationStatics.BeginImpersonation(UserObject), actionGetter: () => new PostBackAction(new ExternalResource(ReturnUrl)))).Add(new Paragraph("Please wait.".ToComponents()))); } var content = new BasicPageContent(bodyClasses: elementClass); content.Add(new PageName()); if (ConfigurationStatics.IsLiveInstallation) { content.Add( new Paragraph( new ImportantContent("Warning:".ToComponents()).ToCollection() .Concat( " Do not impersonate a user without permission. Your actions will be attributed to the user you are impersonating, not to you.".ToComponents()) .Materialize())); } var user = new DataValue <User>(); var pb = PostBack.CreateFull( modificationMethod: () => UserImpersonationStatics.BeginImpersonation(user.Value), actionGetter: () => new PostBackAction( new ExternalResource( ReturnUrl.Any() ? ReturnUrl : EwfConfigurationStatics.AppConfiguration.DefaultBaseUrl.GetUrlString(EwfConfigurationStatics.AppSupportsSecureConnections)))); FormState.ExecuteWithDataModificationsAndDefaultAction( pb.ToCollection(), () => { content.Add( new EmailAddressControl( "", true, validationMethod: (postBackValue, validator) => { if (!postBackValue.Any()) { user.Value = null; return; } user.Value = UserManagementStatics.SystemProvider.GetUser(postBackValue); if (user.Value == null) { validator.NoteErrorAndAddMessage("The email address you entered does not match a user."); } }).ToFormItem(label: "User's email address (leave blank for anonymous)".ToComponents()) .ToComponentCollection() .Append( new Paragraph( new EwfButton( new StandardButtonStyle( AppRequestState.Instance.ImpersonatorExists ? "Change User" : "Begin Impersonation", buttonSize: ButtonSize.Large)) .ToCollection())) .Materialize()); }); return(content); }