protected void Page_Load(object sender, EventArgs e) { Master.DisabledSidePanel = true; if (TenantStatisticsProvider.IsNotPaid()) { Master.TopStudioPanel.DisableProductNavigation = true; Master.TopStudioPanel.DisableSettings = true; Master.TopStudioPanel.DisableSearch = true; } Title = HeaderStringHelper.GetPageTitle(Resources.Resource.Tariffs); if (CoreContext.Configuration.Standalone) { pageContainer.Controls.Add(LoadControl(TariffStandalone.Location)); } else { pageContainer.Controls.Add(LoadControl(TariffUsage.Location)); var payments = CoreContext.PaymentManager.GetTariffPayments(TenantProvider.CurrentTenantID).ToList(); if (payments.Any() && !TenantExtra.GetTenantQuota().Trial && CoreContext.UserManager.IsUserInGroup(SecurityContext.CurrentAccount.ID, ASC.Core.Users.Constants.GroupAdmin.ID)) { var tariffHistory = (TariffHistory)LoadControl(TariffHistory.Location); tariffHistory.Payments = payments; pageContainer.Controls.Add(tariffHistory); } } }
protected string RenderCustomNavigation() { if (TenantStatisticsProvider.IsNotPaid()) { return(string.Empty); } var sb = new StringBuilder(); _customNavItems.Reverse(); string rendered; foreach (var item in _customNavItems) { var render = WebItemManager.Instance[item.ID] as IRenderCustomNavigation; if (render == null) { continue; } rendered = render.RenderCustomNavigation(Page); if (!string.IsNullOrEmpty(rendered)) { sb.Append(rendered); } } rendered = Studio.Feed.RenderCustomNavigation(Page); if (!string.IsNullOrEmpty(rendered)) { sb.Append(rendered); } return(sb.ToString()); }
public void ProcessRequest(HttpContext context) { if (TenantStatisticsProvider.IsNotPaid()) { context.Response.StatusCode = (int)HttpStatusCode.PaymentRequired; context.Response.StatusDescription = "Payment Required."; return; } try { switch ((context.Request[FilesLinkUtility.Action] ?? "").ToLower()) { case "redirect": Redirect(context); break; case "webhook": Webhook(context); break; default: throw new HttpException((int)HttpStatusCode.BadRequest, FilesCommonResource.ErrorMassage_BadRequest); } } catch (InvalidOperationException e) { throw new HttpException((int)HttpStatusCode.InternalServerError, FilesCommonResource.ErrorMassage_BadRequest, e); } }
public override void OnProcessRequest(HttpContext context) { if (TenantStatisticsProvider.IsNotPaid()) { context.Response.StatusCode = (int)HttpStatusCode.PaymentRequired; context.Response.StatusDescription = "Payment Required."; return; } try { switch ((context.Request[FilesLinkUtility.Action] ?? "").ToLower()) { case "view": case "download": DownloadFile(context); break; case "bulk": BulkDownloadFile(context); break; case "stream": StreamFile(context); break; case "empty": EmptyFile(context); break; case "tmp": TempFile(context); break; case "create": CreateFile(context); break; case "redirect": Redirect(context); break; case "diff": DifferenceFile(context); break; case "track": TrackFile(context); break; default: throw new HttpException((int)HttpStatusCode.BadRequest, FilesCommonResource.ErrorMassage_BadRequest); } } catch (InvalidOperationException e) { throw new HttpException((int)HttpStatusCode.InternalServerError, FilesCommonResource.ErrorMassage_BadRequest, e); } }
public override void OnProcessRequest(HttpContext context) { if (TenantStatisticsProvider.IsNotPaid()) { context.Response.Redirect(TenantExtra.GetTariffPageLink()); } try { switch ((context.Request[FilesLinkUtility.Action] ?? "").ToLower()) { case "view": DownloadFile(context, true); break; case "download": DownloadFile(context, false); break; case "bulk": BulkDownloadFile(context); break; case "stream": StreamFile(context); break; case "create": CreateFile(context); break; case "redirect": Redirect(context); break; case "diff": DifferenceFile(context); break; case "track": TrackFile(context); break; case "license": License(context); break; default: throw new HttpException((int)HttpStatusCode.BadRequest, FilesCommonResource.ErrorMassage_BadRequest); } } catch (InvalidOperationException e) { throw new HttpException((int)HttpStatusCode.InternalServerError, FilesCommonResource.ErrorMassage_BadRequest, e); } }
public object GetTenantExtra() { return(new { opensource = TenantExtra.Opensource, enterprise = TenantExtra.Enterprise, tariff = TenantExtra.GetCurrentTariff(), quota = TenantExtra.GetTenantQuota(), notPaid = TenantStatisticsProvider.IsNotPaid(), licenseAccept = Web.Studio.UserControls.Management.TariffSettings.LicenseAccept }); }
private void InitStudioSettingsInlineScript() { var paid = !TenantStatisticsProvider.IsNotPaid(); var showPromotions = paid && PromotionsSettings.Load().Show; var showTips = !Request.DesktopApp() && paid && TipsSettings.LoadForCurrentUser().Show; var script = new StringBuilder(); script.AppendFormat("window.ASC.Resources.Master.ShowPromotions={0};", showPromotions.ToString().ToLowerInvariant()); script.AppendFormat("window.ASC.Resources.Master.ShowTips={0};", showTips.ToString().ToLowerInvariant()); RegisterInlineScript(script.ToString(), true, false); }
protected void Page_Load(object sender, EventArgs e) { Master.DisabledSidePanel = true; if (TenantStatisticsProvider.IsNotPaid()) { Master.TopStudioPanel.DisableProductNavigation = true; Master.TopStudioPanel.DisableSettings = true; Master.TopStudioPanel.DisableSearch = true; } Title = HeaderStringHelper.GetPageTitle(Resources.Resource.Tariffs); pageContainer.Controls.Add(LoadControl(TariffSettings.Location)); }
public object GetTenantExtra() { return(new { customMode = CoreContext.Configuration.CustomMode, opensource = TenantExtra.Opensource, enterprise = TenantExtra.Enterprise, tariff = TenantExtra.GetCurrentTariff(), quota = TenantExtra.GetTenantQuota(), notPaid = TenantStatisticsProvider.IsNotPaid(), licenseAccept = Web.Studio.UserControls.Management.TariffSettings.LicenseAccept, enableTariffPage = //TenantExtra.EnableTariffSettings - think about hide-settings for opensource (!CoreContext.Configuration.Standalone || !string.IsNullOrEmpty(LicenseReader.LicensePath)) && string.IsNullOrEmpty(SetupInfo.AmiMetaUrl) && !CoreContext.Configuration.CustomMode }); }
public void OnResourceExecuting(ResourceExecutingContext context) { if (context.ActionDescriptor is ControllerActionDescriptor controllerActionDescriptor && !controllerActionDescriptor.EndpointMetadata.OfType <CustomHttpMethodAttribute>().FirstOrDefault().Check) { log.Debug("Payment is not required"); return; } var header = context.HttpContext.Request.Headers["Payment-Info"]; if (string.IsNullOrEmpty(header) || (bool.TryParse(header, out var flag) && flag)) { if (TenantStatisticsProvider.IsNotPaid()) { context.Result = new StatusCodeResult((int)HttpStatusCode.PaymentRequired); log.WarnFormat("Payment Required {0}.", context.HttpContext.Request.Url()); } } }
protected void Page_Load(object sender, EventArgs e) { if (DebugInfo.ShowDebugInfo) { debugInfoPopUpContainer.Options.IsPopup = true; } if (Page is Auth || Page is _Default) { CurrentProductID = Guid.Empty; } else { CurrentProductID = !String.IsNullOrEmpty(Request["productID"]) ? new Guid(Request["productID"]) : CommonLinkUtility.GetProductID(); if (!String.IsNullOrEmpty(Request["moduleID"])) { CurrentModuleID = new Guid(Request["moduleID"]); } } CurrentProduct = (IProduct)WebItemManager.Instance[CurrentProductID]; if (SecurityContext.CurrentAccount.IsAuthenticated && !TenantStatisticsProvider.IsNotPaid()) { Page.RegisterBodyScripts(ResolveUrl("~/UserControls/Common/TopStudioPanel/js/FeedReaderScripts.js")); } RenderVideoHandlers(); if (!DisableSearch) { RenderSearchProducts(); DisableSearch = DisableSearch || !SearchProducts.Any() || CoreContext.Configuration.YourDocs; } _guestInfoHolder.Visible = false; _userInfoHolder.Visible = (!DisableUserInfo.HasValue || !DisableUserInfo.Value) && SecurityContext.IsAuthenticated && !(Page is Wizard); ShowTopPanelNavigation = SecurityContext.IsAuthenticated && !(Page is Wizard); if (SecurityContext.IsAuthenticated) { CurrentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID); } TariffNotify = TenantExtra.GetTariffNotify(); if (!SecurityContext.IsAuthenticated || !TenantExtra.EnableTarrifSettings || CoreContext.Configuration.YourDocs || CurrentUser.IsVisitor()) { DisableTariffNotify = true; DisableTariff = true; } else if (string.IsNullOrEmpty(TariffNotify)) { DisableTariffNotify = true; } _customNavItems = WebItemManager.Instance.GetItems(WebZoneType.CustomProductList, ItemAvailableState.Normal); if (CurrentUser.IsVisitor()) { _customNavItems.RemoveAll(item => item.ID == WebItemManager.MailProductID); // remove mail for guest } if (DisableProductNavigation) { _productListHolder.Visible = false; } else { var productsList = WebItemManager.Instance.GetItems(WebZoneType.TopNavigationProductList, ItemAvailableState.Normal); //.Where(pr => !CurrentProductID.Equals(pr.ID)); DisplayModuleList = productsList.Any() && !CoreContext.Configuration.YourDocs; _productRepeater.DataSource = productsList; _productRepeater.DataBind(); var addons = _customNavItems.Where(pr => ((pr.ID == WebItemManager.CalendarProductID || pr.ID == WebItemManager.TalkProductID || pr.ID == WebItemManager.MailProductID))); //if (GetCurrentWebItem != null) // _addons = _addons.Where(pr => pr.ID != GetCurrentWebItem.ID); _addonRepeater.DataSource = addons.ToList(); _addonRepeater.DataBind(); MoreProductsRepeater.DataBind(); } foreach (var item in _customNavItems) { var render = WebItemManager.Instance[item.ID] as IRenderCustomNavigation; if (render == null) { continue; } try { var control = render.LoadCustomNavigationControl(Page); if (control != null) { _customNavControls.Controls.Add(control); } } catch (Exception ex) { log4net.LogManager.GetLogger("ASC.Web.Studio").Error(ex); } } }
protected void Page_PreInit(object sender, EventArgs e) { if (CheckWizardCompleted) { var s = WizardSettings.Load(); if (!s.Completed) { Response.Redirect("~/Wizard.aspx"); } } //check auth if (!SecurityContext.IsAuthenticated && !AuthByCookies() && !MayNotAuth) { if (TenantAccessSettings.Load().Anyone) { OutsideAuth(); } else { var refererURL = GetRefererUrl(); Session["refererURL"] = refererURL; var authUrl = "~/Auth.aspx"; if (Request.DesktopApp()) { authUrl += "?desktop=" + Request["desktop"]; } Response.Redirect(authUrl, true); } } var user = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID); if (!MayNotPaid && TenantExtra.EnableTarrifSettings && (TenantStatisticsProvider.IsNotPaid() || TenantExtra.UpdatedWithoutLicense) && WarmUp.Instance.CheckCompleted() && Request.QueryString["warmup"] != "true") { if (TariffSettings.HidePricingPage && !user.IsAdmin()) { Response.StatusCode = (int)HttpStatusCode.PaymentRequired; Response.End(); } else { Response.Redirect(TenantExtra.GetTariffPageLink() + (Request.DesktopApp() ? "?desktop=true" : ""), true); } } if (!MayPhoneNotActivate && SecurityContext.IsAuthenticated) { if (StudioSmsNotificationSettings.IsVisibleSettings && StudioSmsNotificationSettings.Enable && (string.IsNullOrEmpty(user.MobilePhone) || user.MobilePhoneActivationStatus == MobilePhoneActivationStatus.NotActivated)) { Response.Redirect(CommonLinkUtility.GetConfirmationUrl(user.Email, ConfirmType.PhoneActivation), true); } if (TfaAppAuthSettings.IsVisibleSettings && TfaAppAuthSettings.Enable && !TfaAppUserSettings.EnableForUser(user.ID)) { Response.Redirect(CommonLinkUtility.GetConfirmationUrl(user.Email, ConfirmType.TfaActivation), true); } } //check disable and public var webitem = CommonLinkUtility.GetWebItemByUrl(Request.Url.ToString()); var parentIsDisabled = false; if (webitem != null && webitem.IsSubItem()) { var parentItemID = WebItemManager.Instance.GetParentItemID(webitem.ID); parentIsDisabled = WebItemManager.Instance[parentItemID].IsDisabled(); } if (webitem != null && (webitem.IsDisabled() || parentIsDisabled) && !MayNotAuth) { if (webitem.ID == WebItemManager.PeopleProductID && string.Equals(GetType().BaseType.FullName, "ASC.Web.People.Profile")) { Response.Redirect("~/My.aspx", true); } Response.Redirect("~/", true); } if (SecurityContext.IsAuthenticated && !CoreContext.Configuration.Personal) { try { StatisticManager.SaveUserVisit(TenantProvider.CurrentTenantID, SecurityContext.CurrentAccount.ID, CommonLinkUtility.GetProductID()); } catch (Exception exc) { Log.Error("failed save user visit", exc); } } }
protected void Page_PreInit(object sender, EventArgs e) { if (CoreContext.Configuration.Standalone && !(this is Wizard)) { var s = SettingsManager.Instance.LoadSettings <WizardSettings>(TenantProvider.CurrentTenantID); if (!s.Completed) { Response.Redirect("~/wizard.aspx"); } } //check auth if (!SecurityContext.IsAuthenticated && !AuthByCookies() && !MayNotAuth) { var refererURL = GetRefererUrl(); Session["refererURL"] = refererURL; Response.Redirect("~/auth.aspx", true); } if (!MayNotPaid && TenantStatisticsProvider.IsNotPaid()) { Response.Redirect(TenantExtra.GetTariffPageLink(), true); } else if (SecurityContext.IsAuthenticated && StudioSmsNotificationSettings.IsVisibleSettings && StudioSmsNotificationSettings.Enable && !MayPhoneNotActivate) { var user = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID); if (!CoreContext.UserManager.IsUserInGroup(SecurityContext.CurrentAccount.ID, Constants.GroupAdmin.ID) && (string.IsNullOrEmpty(user.MobilePhone) || user.MobilePhoneActivationStatus == MobilePhoneActivationStatus.NotActivated)) { Response.Redirect(CommonLinkUtility.GetConfirmationUrl(user.Email, ConfirmType.PhoneActivation)); } } //check disable and public var webitem = CommonLinkUtility.GetWebItemByUrl(Request.Url.ToString()); var parentIsDisabled = false; if (webitem != null && webitem.IsSubItem()) { var parentItemID = WebItemManager.Instance.GetParentItemID(webitem.ID); parentIsDisabled = WebItemManager.Instance[parentItemID].IsDisabled(); } if (webitem != null && (webitem.IsDisabled() || parentIsDisabled) && !MayNotAuth) { if (webitem.ID == new Guid("{F4D98AFD-D336-4332-8778-3C6945C81EA0}") && string.Equals(GetType().BaseType.FullName, "ASC.Web.People.Profile")) { Response.Redirect("~/my.aspx", true); } Response.Redirect("~/", true); } if (SecurityContext.IsAuthenticated) { try { StatisticManager.SaveUserVisit(TenantProvider.CurrentTenantID, SecurityContext.CurrentAccount.ID, CommonLinkUtility.GetProductID()); } catch (Exception exc) { Log.Error("failed save user visit", exc); } } }
public override void OnProcessRequest(HttpContext context) { var action = context.Request[CommonLinkUtility.Action]; if (string.IsNullOrEmpty(action)) { throw new HttpException((int)HttpStatusCode.BadRequest, FilesCommonResource.ErrorMassage_BadRequest); } action = action.ToLower(); var publicActions = new[] { "view", "download", "save", "stream" }; if (!publicActions.Contains(action) && !SecurityContext.AuthenticateMe(CookiesManager.GetCookies(CookiesType.AuthKey))) { context.Response.Redirect("~/"); return; } if (TenantStatisticsProvider.IsNotPaid()) { context.Response.Redirect(TenantExtra.GetTariffPageLink()); } try { switch (action) { case "view": DownloadFile(context, true); break; case "download": DownloadFile(context, false); break; case "bulk": BulkDownloadFile(context); break; case "save": SaveFile(context); break; case "stream": StreamFile(context); break; case "create": CreateFile(context); break; case "redirect": Redirect(context); break; default: throw new InvalidOperationException(); } } catch (InvalidOperationException e) { throw new HttpException((int)HttpStatusCode.InternalServerError, FilesCommonResource.ErrorMassage_BadRequest, e); } }
protected void Page_PreInit(object sender, EventArgs e) { ProcessSecureFilter(); var wizardSettings = SettingsManager.Instance.LoadSettings <WizardSettings>(TenantProvider.CurrentTenantID); if (Request["first"] == "1" && !string.IsNullOrEmpty(Request["id"]) && wizardSettings.Completed) { // wizardSettings.Completed - open source, Request["first"] - cloud wizardSettings.Completed = false; SettingsManager.Instance.SaveSettings(wizardSettings, TenantProvider.CurrentTenantID); } var authCookie = Request["id"] ?? CookiesManager.GetCookies(CookiesType.AuthKey); if (!wizardSettings.Completed && !(this is confirm)) { var successAuth = SecurityContext.IsAuthenticated; if (!successAuth) { successAuth = AuthByCookies(authCookie); if (successAuth) { CookiesManager.SetCookies(CookiesType.AuthKey, authCookie); } else { try { authCookie = SecurityContext.AuthenticateMe(UserManagerWrapper.AdminID.ToString(), "admin"); successAuth = true; } catch (System.Security.Authentication.InvalidCredentialException) { } catch (System.Security.SecurityException) { } } } if (!successAuth && !(this is Auth)) { Response.Redirect("~/auth.aspx"); } if (successAuth && !(this is Wizard)) { Response.Redirect("~/wizard.aspx"); } } else if (!SecurityContext.IsAuthenticated && wizardSettings.Completed && !(this is confirm)) { if (this is Auth && Session["refererURL"] == null && !string.IsNullOrEmpty(Request["id"])) { if (AuthByCookies(authCookie)) { CookiesManager.SetCookies(CookiesType.AuthKey, authCookie); var first = Request["first"] == "1"; if (first) { try { var tenant = CoreContext.TenantManager.GetCurrentTenant(false); tenant.Name = Resources.Resource.StudioWelcomeHeader; CoreContext.TenantManager.SaveTenant(tenant); } catch { } } Response.Redirect(VirtualPathUtility.ToAbsolute("~/") + (first ? "?first=1" : "")); return; } } //for redirect into one of the projects after creating new tenant else if (Session["refererURL"] == null && !string.IsNullOrEmpty(Request["id"])) { if (AuthByCookies(authCookie)) { CookiesManager.SetCookies(CookiesType.AuthKey, authCookie); try { var tenant = CoreContext.TenantManager.GetCurrentTenant(false); tenant.Name = Resources.Resource.StudioWelcomeHeader; CoreContext.TenantManager.SaveTenant(tenant); } catch { Log.Error("Can't set current tenant in MainPage"); } var refererURL = GetRefererUrl(); if (String.IsNullOrEmpty(refererURL)) { Response.Redirect("~/auth.aspx"); } else { var currentUser = CoreContext.UserManager.GetUsers(CoreContext.TenantManager.GetCurrentTenant().OwnerId); if (!currentUser.IsOwner()) { Response.Redirect("~/auth.aspx"); } SecurityContext.AuthenticateMe(CoreContext.Authentication.GetAccountByID(currentUser.ID)); FirstTimeTenantSettings.SetDefaultTenantSettings(); FirstTimeTenantSettings.SendInstallInfo(currentUser); Response.Redirect(refererURL); } } } if (!(this is Auth) && !AutoAuthByCookies() && !ExclusivePage()) { var refererURL = GetRefererUrl(); Session["refererURL"] = refererURL; Response.Redirect("~/auth.aspx"); return; } } if (TenantStatisticsProvider.IsNotPaid() && !(this is Auth || this is Tariffs || this is confirm)) { Response.Redirect(TenantExtra.GetTariffPageLink(), true); } else if (SecurityContext.IsAuthenticated && StudioSmsNotificationSettings.IsVisibleSettings && StudioSmsNotificationSettings.Enable && !(this is confirm || this is Auth)) { var user = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID); if (!CoreContext.UserManager.IsUserInGroup(SecurityContext.CurrentAccount.ID, Constants.GroupAdmin.ID) && (string.IsNullOrEmpty(user.MobilePhone) || user.MobilePhoneActivationStatus == MobilePhoneActivationStatus.NotActivated)) { Response.Redirect(StudioNotifyService.GenerateConfirmUrl(user.Email, ConfirmType.PhoneActivation)); } } //check disable and public var webitem = CommonLinkUtility.GetWebItemByUrl(Request.Url.ToString()); var parentIsDisabled = false; if (webitem != null && webitem.IsSubItem()) { var parentItemID = WebItemManager.Instance.GetParentItemID(webitem.ID); parentIsDisabled = WebItemManager.Instance[parentItemID].IsDisabled(); } if (webitem != null && (webitem.IsDisabled() || parentIsDisabled) && !ExclusivePage()) { if (webitem.ID == new Guid("{F4D98AFD-D336-4332-8778-3C6945C81EA0}") && string.Equals(GetType().BaseType.FullName, "ASC.Web.People.Profile")) { Response.Redirect("~/my.aspx"); return; } Response.Redirect("~/"); return; } if (SecurityContext.IsAuthenticated) { try { StatisticManager.SaveUserVisit(TenantProvider.CurrentTenantID, SecurityContext.CurrentAccount.ID, CommonLinkUtility.GetProductID()); } catch (Exception exc) { Log.Error("failed save user visit", exc); } } PersonalHelper.TransferRequest(this); }