private void AuthRedirect(bool first) { var wizardSettings = WizardSettings.Load(); if (first && wizardSettings.Completed) { wizardSettings.Completed = false; wizardSettings.Save(); } string url; if (wizardSettings.Completed) { url = CommonLinkUtility.GetDefault(); } else { url = SecurityContext.IsAuthenticated ? "~/wizard.aspx" : "~/auth.aspx"; } if (Request.DesktopApp()) { if (wizardSettings.Completed) { url = WebItemManager.Instance[WebItemManager.DocumentsProductID].StartURL; } url += "?desktop=true&first=true"; } Response.Redirect(url, true); }
public FileUploadResult ProcessUpload(HttpContext context) { var result = new FileUploadResult(); try { if (!SecurityContext.IsAuthenticated && WizardSettings.Load().Completed) { throw new SecurityException(Resource.PortalSecurity); } if (context.Request.Files.Count == 0) { throw new Exception(Resource.ErrorEmptyUploadFileSelected); } var licenseFile = context.Request.Files[0]; var dueDate = LicenseReader.SaveLicenseTemp(licenseFile.InputStream); result.Message = dueDate >= DateTime.UtcNow.Date ? Resource.LicenseUploaded : string.Format( (TenantExtra.GetTenantQuota().Update ? Resource.LicenseUploadedOverdueSupport : Resource.LicenseUploadedOverdue), "<span class='tariff-marked'>", "</span>", dueDate.Date.ToLongDateString()); result.Success = true; } catch (LicenseExpiredException ex) { Log.Error("License upload", ex); result.Message = Resource.LicenseErrorExpired; } catch (LicenseQuotaException ex) { Log.Error("License upload", ex); result.Message = Resource.LicenseErrorQuota; } catch (LicensePortalException ex) { Log.Error("License upload", ex); result.Message = Resource.LicenseErrorPortal; } catch (Exception ex) { Log.Error("License upload", ex); result.Message = Resource.LicenseError; } return(result); }
protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); var wizardSettings = WizardSettings.Load(); if (wizardSettings.Completed) { Response.Redirect(CommonLinkUtility.GetDefault()); } if (CoreContext.Configuration.Personal) { Context.Response.Redirect(FilesLinkUtility.FilesBaseAbsolutePath); } }
public static void SendInstallInfo(UserInfo user) { if (!TenantExtra.Opensource) { return; } if (!WizardSettings.Load().Analytics) { return; } try { var url = ConfigurationManagerExtension.AppSettings["web.install-url"]; if (string.IsNullOrEmpty(url)) { return; } var tenant = CoreContext.TenantManager.GetCurrentTenant(); var q = new MailQuery { Email = user.Email, Id = CoreContext.Configuration.GetKey(tenant.TenantId), Alias = tenant.TenantDomain, }; var index = url.IndexOf("?v=", StringComparison.InvariantCultureIgnoreCase); if (0 < index) { q.Version = url.Substring(index + 3) + Environment.OSVersion; url = url.Substring(0, index); } using (var webClient = new WebClient()) { var values = new NameValueCollection { { "query", Signature.Create(q, "4be71393-0c90-41bf-b641-a8d9523fba5c") } }; webClient.UploadValues(url, values); } } catch (Exception error) { LogManager.GetLogger("ASC.Web").Error(error); } }
public WizardSettings CompleteWizard() { SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings); var settings = WizardSettings.Load(); if (settings.Completed) { return(settings); } settings.Completed = true; settings.Save(); return(settings); }
public FileUploadResult ProcessUpload(HttpContext context) { var result = new FileUploadResult(); try { if (!SecurityContext.IsAuthenticated && WizardSettings.Load().Completed) { throw new SecurityException(Resource.PortalSecurity); } if (context.Request.Files.Count == 0) { throw new Exception(Resource.ErrorEmptyUploadFileSelected); } var licenseFile = context.Request.Files[0]; LicenseReader.SaveLicenseTemp(licenseFile.InputStream); result.Message = Resource.LicenseUploaded; result.Success = true; } catch (LicenseExpiredException ex) { LogManager.GetLogger(typeof(LicenseReader)).Error("License upload", ex); result.Message = Resource.LicenseErrorExpired; } catch (LicenseQuotaException ex) { LogManager.GetLogger(typeof(LicenseReader)).Error("License upload", ex); result.Message = Resource.LicenseErrorQuota; } catch (LicensePortalException ex) { LogManager.GetLogger(typeof(LicenseReader)).Error("License upload", ex); result.Message = Resource.LicenseErrorPortal; } catch (Exception ex) { LogManager.GetLogger(typeof(LicenseReader)).Error("License upload", ex); result.Message = Resource.LicenseError; } return(result); }
protected void Page_Load(object sender, EventArgs e) { if (CoreContext.Configuration.CustomMode) { return; } Page .RegisterStyle("~/UserControls/Statistics/PortalAnalytics/css/portalanalytics.less") .RegisterBodyScripts("~/UserControls/Statistics/PortalAnalytics/js/portalanalytics.js"); if (TenantExtra.Opensource) { Enabled = true; SwitchedOn = WizardSettings.Load().Analytics; } else if (TenantExtra.Saas && SetupInfo.CustomScripts.Length != 0) { Enabled = true; SwitchedOn = TenantAnalyticsSettings.Load().Analytics; } }
public bool UpdatePortalAnalytics(bool enable) { SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings); if (!(TenantExtra.Opensource || (TenantExtra.Saas && SetupInfo.CustomScripts.Length != 0)) || CoreContext.Configuration.CustomMode) { throw new SecurityException(); } if (TenantExtra.Opensource) { var wizardSettings = WizardSettings.Load(); wizardSettings.Analytics = enable; wizardSettings.Save(); } else if (TenantExtra.Saas) { var analyticsSettings = TenantAnalyticsSettings.Load(); analyticsSettings.Analytics = enable; analyticsSettings.Save(); } return(enable); }
public object SaveData(string email, string pwd, string lng, string promocode, string amiid, bool analytics) { try { var tenant = CoreContext.TenantManager.GetCurrentTenant(); var settings = WizardSettings.Load(); if (settings.Completed) { throw new Exception("Wizard passed."); } if (IsAmi && IncorrectAmiId(amiid)) { throw new Exception(Resource.EmailAndPasswordIncorrectAmiId); } if (tenant.OwnerId == Guid.Empty) { Thread.Sleep(TimeSpan.FromSeconds(6)); // wait cache interval tenant = CoreContext.TenantManager.GetTenant(tenant.TenantId); if (tenant.OwnerId == Guid.Empty) { LogManager.GetLogger("ASC.Web.FirstTime").Error(tenant.TenantId + ": owner id is empty."); } } var currentUser = CoreContext.UserManager.GetUsers(CoreContext.TenantManager.GetCurrentTenant().OwnerId); var cookie = SecurityContext.AuthenticateMe(currentUser.ID); CookiesManager.SetCookies(CookiesType.AuthKey, cookie); if (!UserManagerWrapper.ValidateEmail(email)) { throw new Exception(Resource.EmailAndPasswordIncorrectEmail); } UserManagerWrapper.CheckPasswordPolicy(pwd); SecurityContext.SetUserPassword(currentUser.ID, pwd); email = email.Trim(); if (currentUser.Email != email) { currentUser.Email = email; currentUser.ActivationStatus = EmployeeActivationStatus.NotActivated; } CoreContext.UserManager.SaveUserInfo(currentUser); if (!string.IsNullOrWhiteSpace(promocode)) { try { CoreContext.PaymentManager.ActivateKey(promocode); } catch (Exception err) { LogManager.GetLogger("ASC.Web.FirstTime").Error("Incorrect Promo: " + promocode, err); throw new Exception(Resource.EmailAndPasswordIncorrectPromocode); } } if (RequestLicense) { TariffSettings.LicenseAccept = true; MessageService.Send(HttpContext.Current.Request, MessageAction.LicenseKeyUploaded); LicenseReader.RefreshLicense(); } if (TenantExtra.Opensource) { settings.Analytics = analytics; } settings.Completed = true; settings.Save(); TrySetLanguage(tenant, lng); StudioNotifyService.Instance.SendCongratulations(currentUser); FirstTimeTenantSettings.SendInstallInfo(currentUser); return(new { Status = 1, Message = Resource.EmailAndPasswordSaved }); } catch (BillingNotFoundException) { return(new { Status = 0, Message = UserControlsCommonResource.LicenseKeyNotFound }); } catch (BillingNotConfiguredException) { return(new { Status = 0, Message = UserControlsCommonResource.LicenseKeyNotCorrect }); } catch (BillingException) { return(new { Status = 0, Message = UserControlsCommonResource.LicenseException }); } catch (Exception ex) { LogManager.GetLogger("ASC.Web.FirstTime").Error(ex); return(new { Status = 0, Message = ex.Message }); } }
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_Load(object sender, EventArgs e) { InitScripts(); HubUrl = ConfigurationManager.AppSettings["web.hub"] ?? string.Empty; if (!_enableWebChat.HasValue || _enableWebChat.Value) { EnabledWebChat = Convert.ToBoolean(ConfigurationManager.AppSettings["web.chat"] ?? "false") && WebItemManager.Instance.GetItems(WebZoneType.CustomProductList, ItemAvailableState.Normal). Any(id => id.ID == WebItemManager.TalkProductID) && !(Request.Browser != null && Request.Browser.Browser == "IE" && (Request.Browser.MajorVersion == 8 || Request.Browser.MajorVersion == 9 || Request.Browser.MajorVersion == 10)); } IsMobile = MobileDetector.IsMobile; if (!DisabledSidePanel && EnabledWebChat && !IsMobile) { SmallChatHolder.Controls.Add(LoadControl(UserControls.Common.SmallChat.SmallChat.Location)); } if (!DisabledSidePanel && !CoreContext.Configuration.Personal) { /** InvitePanel popup **/ InvitePanelHolder.Controls.Add(LoadControl(InvitePanel.Location)); } if ((!DisabledSidePanel || !DisabledTopStudioPanel) && !TopStudioPanel.DisableSettings && HubUrl != string.Empty && SecurityContext.IsAuthenticated) { AddBodyScripts(ResolveUrl, "~/js/third-party/socket.io.js", "~/js/asc/core/asc.socketio.js"); } if (!DisabledTopStudioPanel) { TopContent.Controls.Add(TopStudioPanel); } if (!EmailActivated && !CoreContext.Configuration.Personal && SecurityContext.IsAuthenticated && EmailActivationSettings.LoadForCurrentUser().Show) { activateEmailPanel.Controls.Add(LoadControl(ActivateEmailPanel.Location)); } if (AffiliateHelper.BannerAvailable || CoreContext.Configuration.Personal) { BannerHolder.Controls.Add(LoadControl(Banner.Location)); } if (ThirdPartyBanner.Display) { BannerHolder.Controls.Add(LoadControl(ThirdPartyBanner.Location)); } var curUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID); if (!DisabledSidePanel) { TariffNotifyHolder.Controls.Add(LoadControl(TariffNotify.Location)); } if (curUser.IsVisitor() && !curUser.IsOutsider()) { var collaboratorPopupSettings = CollaboratorSettings.LoadForCurrentUser(); if (collaboratorPopupSettings.FirstVisit) { AddBodyScripts(ResolveUrl, "~/js/asc/core/collaborators.js"); } } #region third-party scripts if (TenantExtra.Saas) { if (SetupInfo.CustomScripts.Length != 0) { GoogleTagManagerPlaceHolder.Controls.Add(LoadControl("~/UserControls/Common/ThirdPartyScripts/GoogleTagManagerScript.ascx")); if (!CoreContext.Configuration.Personal) { GoogleAnalyticsScriptPlaceHolder.Controls.Add(LoadControl("~/UserControls/Common/ThirdPartyScripts/GoogleAnalyticsScript.ascx")); } else { GoogleAnalyticsScriptPlaceHolder.Controls.Add(LoadControl("~/UserControls/Common/ThirdPartyScripts/GoogleAnalyticsScriptPersonal.ascx")); } } } else if (TenantExtra.Opensource && WizardSettings.Load().Analytics && SecurityContext.IsAuthenticated) { GoogleTagManagerPlaceHolder.Controls.Add(LoadControl("~/UserControls/Common/ThirdPartyScripts/GoogleTagManagerScript.ascx")); GoogleAnalyticsScriptPlaceHolder.Controls.Add(LoadControl("~/UserControls/Common/ThirdPartyScripts/GoogleAnalyticsScriptOpenSource.ascx")); } #endregion }