public object RestoreGreetingSettings() { try { SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings); _tenantInfoSettings = SettingsManager.Instance.LoadSettings <TenantInfoSettings>(TenantProvider.CurrentTenantID); _tenantInfoSettings.RestoreDefault(); SettingsManager.Instance.SaveSettings <TenantInfoSettings>(_tenantInfoSettings, TenantProvider.CurrentTenantID); AdminLog.PostAction("Settings: restored previous greeting settings"); return(new { Status = 1, Message = Resources.Resource.SuccessfullySaveGreetingSettingsMessage, LogoPath = _tenantInfoSettings.GetAbsoluteCompanyLogoPath(), CompanyName = CoreContext.TenantManager.GetCurrentTenant().Name, }); } catch (Exception e) { return(new { Status = 0, Message = e.Message.HtmlEncode() }); } }
public static string GetLogo(WhiteLabelLogoTypeEnum type, bool general = true, bool isDefIfNoWhiteLabel = false) { var imgUrl = ""; if (TenantLogoManager.WhiteLabelEnabled) { var _tenantWhiteLabelSettings = TenantWhiteLabelSettings.Load(); return(_tenantWhiteLabelSettings.GetAbsoluteLogoPath(type, general)); } else { if (isDefIfNoWhiteLabel) { imgUrl = TenantWhiteLabelSettings.GetAbsoluteDefaultLogoPath(type, general); } else { if (type == WhiteLabelLogoTypeEnum.Dark) { /*** simple scheme ***/ var _tenantInfoSettings = TenantInfoSettings.Load(); imgUrl = _tenantInfoSettings.GetAbsoluteCompanyLogoPath(); /***/ } else { imgUrl = TenantWhiteLabelSettings.GetAbsoluteDefaultLogoPath(type, general); } } } return(imgUrl); }
protected void Page_Load(object sender, EventArgs e) { Page.Title = HeaderStringHelper.GetPageTitle(Resource.AccountControlPageTitle); Master.DisabledSidePanel = true; Master.TopStudioPanel.DisableProductNavigation = true; Master.TopStudioPanel.DisableUserInfo = true; Master.TopStudioPanel.DisableSearch = true; Master.TopStudioPanel.DisableSettings = true; Master.TopStudioPanel.DisableTariff = true; Master.TopStudioPanel.DisableLoginPersonal = true; _tenantInfoSettings = SettingsManager.Instance.LoadSettings <TenantInfoSettings>(TenantProvider.CurrentTenantID); _email = Request["email"] ?? ""; var tenant = CoreContext.TenantManager.GetCurrentTenant(); if (tenant.Status != TenantStatus.Active && _type != ConfirmType.PortalContinue) { Response.Redirect(SetupInfo.NoTenantRedirectURL, true); } if (_type == ConfirmType.PhoneActivation && SecurityContext.IsAuthenticated) { Master.TopStudioPanel.DisableUserInfo = false; } if (!CheckValidationKey()) { return; } LoadControls(); }
public object SaveGreetingLogoSettings(string logoVP) { try { SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings); _tenantInfoSettings = TenantInfoSettings.Load(); if (!String.IsNullOrEmpty(logoVP)) { var fileName = Path.GetFileName(logoVP); var data = UserPhotoManager.GetTempPhotoData(fileName); _tenantInfoSettings.SetCompanyLogo(fileName, data); try { UserPhotoManager.RemoveTempPhoto(fileName); } catch { } } _tenantInfoSettings.Save(); MessageService.Send(HttpContext.Current.Request, MessageAction.GreetingSettingsUpdated); return(new { Status = 1, Message = Resource.SuccessfullySaveGreetingSettingsMessage }); } catch (Exception e) { return(new { Status = 0, Message = e.Message.HtmlEncode() }); } }
public object SaveGreetingLogoSettings(string logoVP) { try { SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings); _tenantInfoSettings = SettingsManager.Instance.LoadSettings<TenantInfoSettings>(TenantProvider.CurrentTenantID); if (!String.IsNullOrEmpty(logoVP)) { var fileName = Path.GetFileName(logoVP); var data = UserPhotoManager.GetTempPhotoData(fileName); _tenantInfoSettings.SetCompanyLogo(fileName, data); try { UserPhotoManager.RemoveTempPhoto(fileName); } catch { } } SettingsManager.Instance.SaveSettings(_tenantInfoSettings, TenantProvider.CurrentTenantID); MessageService.Send(HttpContext.Current.Request, MessageAction.GreetingSettingsUpdated); return new { Status = 1, Message = Resource.SuccessfullySaveGreetingSettingsMessage }; } catch (Exception e) { return new { Status = 0, Message = e.Message.HtmlEncode() }; } }
public object RestoreGreetingLogoSettings() { try { SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings); var tenantId = TenantProvider.CurrentTenantID; _tenantInfoSettings = TenantInfoSettings.Load(); _tenantInfoSettings.RestoreDefault(); _tenantInfoSettings.Save(); if (TenantLogoManager.WhiteLabelEnabled) { var _tenantWhiteLabelSettings = TenantWhiteLabelSettings.Load(); _tenantWhiteLabelSettings.RestoreDefault(WhiteLabelLogoTypeEnum.Dark); _tenantWhiteLabelSettings.Save(tenantId); } return(new { Status = 1, Message = Resource.SuccessfullySaveGreetingSettingsMessage, LogoPath = _tenantInfoSettings.GetAbsoluteCompanyLogoPath() }); } catch (Exception e) { return(new { Status = 0, Message = e.Message.HtmlEncode() }); } }
protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(this.GetType()); this.Page.ClientScript.RegisterClientScriptInclude(GetType(), "ajaxupload_script", VirtualPathUtility.ToAbsolute("~/js/ajaxupload.3.5.js")); Page.ClientScript.RegisterClientScriptInclude(typeof(string), "greetingsettingscontent_script", WebPath.GetPath("usercontrols/management/greetingsettings/js/greetingsettingscontent.js")); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "greetingsettings_style", "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + WebSkin.GetUserSkin().GetAbsoluteWebPath("usercontrols/management/greetingsettings/css/<theme_folder>/greetingsettings.css") + "\">", false); _tenantInfoSettings = SettingsManager.Instance.LoadSettings <TenantInfoSettings>(TenantProvider.CurrentTenantID); }
protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(GetType()); Page.RegisterBodyScripts(VirtualPathUtility.ToAbsolute("~/js/uploader/ajaxupload.js")); Page.RegisterBodyScripts(ResolveUrl("~/usercontrols/management/greetingsettings/js/greetinglogosettings.js")); _tenantInfoSettings = SettingsManager.Instance.LoadSettings<TenantInfoSettings>(TenantProvider.CurrentTenantID); RegisterScript(); }
protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(GetType()); Page.RegisterBodyScripts(VirtualPathUtility.ToAbsolute("~/js/uploader/ajaxupload.js")); Page.RegisterBodyScripts(ResolveUrl("~/usercontrols/management/greetingsettings/js/greetinglogosettings.js")); _tenantInfoSettings = SettingsManager.Instance.LoadSettings <TenantInfoSettings>(TenantProvider.CurrentTenantID); RegisterScript(); }
protected void Page_Load(object sender, EventArgs e) { if (!AvailableControl) { Response.Redirect(CommonLinkUtility.GetDefault(), true); return; } AjaxPro.Utility.RegisterTypeForAjax(GetType()); Page.RegisterBodyScripts("~/js/uploader/ajaxupload.js", "~/UserControls/Management/GreetingSettings/js/greetinglogosettings.js"); _tenantInfoSettings = TenantInfoSettings.Load(); RegisterScript(); }
protected void Page_Load(object sender, EventArgs e) { if (!AvailableControl) { Response.Redirect(CommonLinkUtility.GetDefault(), true); return; } AjaxPro.Utility.RegisterTypeForAjax(GetType()); Page.RegisterBodyScripts("~/js/uploader/ajaxupload.js", "~/usercontrols/management/greetingsettings/js/greetinglogosettings.js"); _tenantInfoSettings = SettingsManager.Instance.LoadSettings <TenantInfoSettings>(TenantProvider.CurrentTenantID); RegisterScript(); }
public void RestoreWhiteLabelOptions() { SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings); if (!TenantLogoManager.WhiteLabelEnabled || !TenantLogoManager.WhiteLabelPaid) { throw new BillingException(Resource.ErrorNotAllowedOption, "WhiteLabel"); } var _tenantWhiteLabelSettings = TenantWhiteLabelSettings.Load(); _tenantWhiteLabelSettings.RestoreDefault(); var _tenantInfoSettings = TenantInfoSettings.Load(); _tenantInfoSettings.RestoreDefaultLogo(); _tenantInfoSettings.Save(); }
public object SaveGreetingSettings(string logoVP, string header) { try { SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings); _tenantInfoSettings = SettingsManager.Instance.LoadSettings <TenantInfoSettings>(TenantProvider.CurrentTenantID); if (!String.IsNullOrEmpty(logoVP)) { var fileName = Path.GetFileName(logoVP); var data = UserPhotoManager.GetTempPhotoData(fileName); _tenantInfoSettings.SetCompanyLogo(fileName, data); try { UserPhotoManager.RemoveTempPhoto(fileName); } catch { } } var currentTenant = CoreContext.TenantManager.GetCurrentTenant(); currentTenant.Name = header; CoreContext.TenantManager.SaveTenant(currentTenant); SettingsManager.Instance.SaveSettings(_tenantInfoSettings, TenantProvider.CurrentTenantID); AdminLog.PostAction("Settings: saved greeting settings with parameters logo={0},header={1}", logoVP, header); MessageService.Send(HttpContext.Current.Request, MessageAction.GreetingSettingsUpdated); return(new { Status = 1, Message = Resource.SuccessfullySaveGreetingSettingsMessage }); } catch (Exception e) { return(new { Status = 0, Message = e.Message.HtmlEncode() }); } }
public object RestoreGreetingSettings() { try { SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings); var _tenantInfoSettings = TenantInfoSettings.Load(); _tenantInfoSettings.RestoreDefaultTenantName(); //_tenantInfoSettings.Save(); return(new { Status = 1, Message = Resource.SuccessfullySaveGreetingSettingsMessage, CompanyName = CoreContext.TenantManager.GetCurrentTenant().Name }); } catch (Exception e) { return(new { Status = 0, Message = e.Message.HtmlEncode() }); } }
protected void Page_Load(object sender, EventArgs e) { Page.RegisterBodyScripts(ResolveUrl("~/usercontrols/management/confirminviteactivation/js/confirm_invite_activation.js")); Page.RegisterStyleControl(VirtualPathUtility.ToAbsolute("~/usercontrols/management/confirminviteactivation/css/confirm_invite_activation.less")); _tenantInfoSettings = SettingsManager.Instance.LoadSettings<TenantInfoSettings>(TenantProvider.CurrentTenantID); var uid = Guid.Empty; try { uid = new Guid(Request["uid"]); } catch { } var email = GetEmailAddress(); if (_type != ConfirmType.Activation && AccountLinkControl.IsNotEmpty && !CoreContext.Configuration.Personal) { var thrd = (AccountLinkControl) LoadControl(AccountLinkControl.Location); thrd.InviteView = true; thrd.ClientCallback = "loginJoinCallback"; thrdParty.Visible = true; thrdParty.Controls.Add(thrd); } Page.Title = HeaderStringHelper.GetPageTitle(Resource.Authorization); UserInfo user; try { SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.CoreSystem); user = CoreContext.UserManager.GetUserByEmail(email); var usr = CoreContext.UserManager.GetUsers(uid); if (usr.ID.Equals(ASC.Core.Users.Constants.LostUser.ID) || usr.ID.Equals(ASC.Core.Configuration.Constants.Guest.ID)) usr = CoreContext.UserManager.GetUsers(CoreContext.TenantManager.GetCurrentTenant().OwnerId); _userAvatar = usr.GetMediumPhotoURL(); _userName = usr.DisplayUserName(true); _userPost = (usr.Title ?? "").HtmlEncode(); } finally { SecurityContext.Logout(); } if (_type == ConfirmType.LinkInvite || _type == ConfirmType.EmpInvite) { if (TenantStatisticsProvider.GetUsersCount() >= TenantExtra.GetTenantQuota().ActiveUsers && _employeeType == EmployeeType.User) { ShowError(UserControlsCommonResource.TariffUserLimitReason); return; } if (!user.ID.Equals(ASC.Core.Users.Constants.LostUser.ID)) { ShowError(CustomNamingPeople.Substitute<Resource>("ErrorEmailAlreadyExists")); return; } } else if (_type == ConfirmType.Activation) { if (user.IsActive) { ShowError(Resource.ErrorConfirmURLError); return; } if (user.ID.Equals(ASC.Core.Users.Constants.LostUser.ID) || user.Status == EmployeeStatus.Terminated) { ShowError(string.Format(Resource.ErrorUserNotFoundByEmail, email)); return; } } var tenant = CoreContext.TenantManager.GetCurrentTenant(); if (tenant != null) { var settings = SettingsManager.Instance.LoadSettings<IPRestrictionsSettings>(tenant.TenantId); if (settings.Enable && !IPSecurity.IPSecurity.Verify(tenant.TenantId)) { ShowError(Resource.ErrorAccessRestricted); return; } } if (!IsPostBack) return; var firstName = GetFirstName(); var lastName = GetLastName(); var pwd = (Request["pwdInput"] ?? "").Trim(); var mustChangePassword = false; LoginProfile thirdPartyProfile; //thirdPartyLogin confirmInvite if (Request["__EVENTTARGET"] == "thirdPartyLogin") { var valueRequest = Request["__EVENTARGUMENT"]; thirdPartyProfile = new LoginProfile(valueRequest); if (!string.IsNullOrEmpty(thirdPartyProfile.AuthorizationError)) { // ignore cancellation if (thirdPartyProfile.AuthorizationError != "Canceled at provider") ShowError(HttpUtility.HtmlEncode(thirdPartyProfile.AuthorizationError)); return; } if (string.IsNullOrEmpty(thirdPartyProfile.EMail)) { ShowError(HttpUtility.HtmlEncode(Resource.ErrorNotCorrectEmail)); return; } } if (Request["__EVENTTARGET"] == "confirmInvite") { if (String.IsNullOrEmpty(email)) { _errorMessage = Resource.ErrorEmptyUserEmail; return; } if (!email.TestEmailRegex()) { _errorMessage = Resource.ErrorNotCorrectEmail; return; } if (String.IsNullOrEmpty(firstName)) { _errorMessage = Resource.ErrorEmptyUserFirstName; return; } if (String.IsNullOrEmpty(lastName)) { _errorMessage = Resource.ErrorEmptyUserLastName; return; } var checkPassResult = CheckPassword(pwd); if (!String.IsNullOrEmpty(checkPassResult)) { _errorMessage = checkPassResult; return; } } var userID = Guid.Empty; try { SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.CoreSystem); if (_type == ConfirmType.EmpInvite || _type == ConfirmType.LinkInvite) { if (TenantStatisticsProvider.GetUsersCount() >= TenantExtra.GetTenantQuota().ActiveUsers && _employeeType == EmployeeType.User) { ShowError(UserControlsCommonResource.TariffUserLimitReason); return; } UserInfo newUser; if (Request["__EVENTTARGET"] == "confirmInvite") { var fromInviteLink = _type == ConfirmType.LinkInvite; newUser = CreateNewUser(firstName, lastName, email, pwd, _employeeType, fromInviteLink); var messageAction = _employeeType == EmployeeType.User ? MessageAction.UserCreatedViaInvite : MessageAction.GuestCreatedViaInvite; MessageService.Send(HttpContext.Current.Request, MessageInitiator.System, messageAction, newUser.DisplayUserName(false)); userID = newUser.ID; } if (Request["__EVENTTARGET"] == "thirdPartyLogin") { if (!String.IsNullOrEmpty(CheckPassword(pwd))) { pwd = UserManagerWrapper.GeneratePassword(); mustChangePassword = true; } var valueRequest = Request["__EVENTARGUMENT"]; thirdPartyProfile = new LoginProfile(valueRequest); newUser = CreateNewUser(GetFirstName(thirdPartyProfile), GetLastName(thirdPartyProfile), GetEmailAddress(thirdPartyProfile), pwd, _employeeType, false); var messageAction = _employeeType == EmployeeType.User ? MessageAction.UserCreatedViaInvite : MessageAction.GuestCreatedViaInvite; MessageService.Send(HttpContext.Current.Request, MessageInitiator.System, messageAction, newUser.DisplayUserName(false)); userID = newUser.ID; if (!String.IsNullOrEmpty(thirdPartyProfile.Avatar)) { SaveContactImage(userID, thirdPartyProfile.Avatar); } var linker = new AccountLinker("webstudio"); linker.AddLink(userID.ToString(), thirdPartyProfile); } } else if (_type == ConfirmType.Activation) { user.ActivationStatus = EmployeeActivationStatus.Activated; user.FirstName = firstName; user.LastName = lastName; CoreContext.UserManager.SaveUserInfo(user); SecurityContext.SetUserPassword(user.ID, pwd); userID = user.ID; //notify if (user.IsVisitor()) { StudioNotifyService.Instance.GuestInfoAddedAfterInvite(user, pwd); MessageService.Send(HttpContext.Current.Request, MessageInitiator.System, MessageAction.GuestActivated, user.DisplayUserName(false)); } else { StudioNotifyService.Instance.UserInfoAddedAfterInvite(user, pwd); MessageService.Send(HttpContext.Current.Request, MessageInitiator.System, MessageAction.UserActivated, user.DisplayUserName(false)); } } } catch (Exception exception) { _errorMessage = HttpUtility.HtmlEncode(exception.Message); return; } finally { SecurityContext.Logout(); } user = CoreContext.UserManager.GetUsers(userID); try { var cookiesKey = SecurityContext.AuthenticateMe(user.Email, pwd); CookiesManager.SetCookies(CookiesType.AuthKey, cookiesKey); MessageService.Send(HttpContext.Current.Request, MessageAction.LoginSuccess); StudioNotifyService.Instance.UserHasJoin(); if (mustChangePassword) { StudioNotifyService.Instance.UserPasswordChange(user); } } catch (Exception exception) { (Page as Confirm).ErrorMessage = HttpUtility.HtmlEncode(exception.Message); return; } UserHelpTourHelper.IsNewUser = true; if (CoreContext.Configuration.Personal) PersonalSettings.IsNewUser = true; Response.Redirect("~/"); }
public string GetLogo() { return(TenantInfoSettings.Load().GetAbsoluteCompanyLogoPath()); }
protected void Page_Load(object sender, EventArgs e) { Page.RegisterBodyScripts(ResolveUrl("~/usercontrols/management/confirminviteactivation/js/confirm_invite_activation.js")); Page.RegisterStyleControl(VirtualPathUtility.ToAbsolute("~/usercontrols/management/confirminviteactivation/css/confirm_invite_activation.less")); _tenantInfoSettings = SettingsManager.Instance.LoadSettings <TenantInfoSettings>(TenantProvider.CurrentTenantID); var uid = Guid.Empty; try { uid = new Guid(Request["uid"]); } catch { } var email = GetEmailAddress(); if (_type != ConfirmType.Activation && AccountLinkControl.IsNotEmpty) { var thrd = (AccountLinkControl)LoadControl(AccountLinkControl.Location); thrd.InviteView = true; thrd.ClientCallback = "loginJoinCallback"; thrdParty.Visible = true; thrdParty.Controls.Add(thrd); } Page.Title = HeaderStringHelper.GetPageTitle(Resource.Authorization); UserInfo user; try { SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.CoreSystem); user = CoreContext.UserManager.GetUserByEmail(email); var usr = CoreContext.UserManager.GetUsers(uid); if (usr.ID.Equals(ASC.Core.Users.Constants.LostUser.ID) || usr.ID.Equals(ASC.Core.Configuration.Constants.Guest.ID)) { usr = CoreContext.UserManager.GetUsers(CoreContext.TenantManager.GetCurrentTenant().OwnerId); } _userAvatar = usr.GetMediumPhotoURL(); _userName = usr.DisplayUserName(true); _userPost = (usr.Title ?? "").HtmlEncode(); } finally { SecurityContext.Logout(); } if (_type == ConfirmType.LinkInvite || _type == ConfirmType.EmpInvite) { if (TenantStatisticsProvider.GetUsersCount() >= TenantExtra.GetTenantQuota().ActiveUsers&& _employeeType == EmployeeType.User) { ShowError(UserControlsCommonResource.TariffUserLimitReason); return; } if (!user.ID.Equals(ASC.Core.Users.Constants.LostUser.ID)) { ShowError(CustomNamingPeople.Substitute <Resource>("ErrorEmailAlreadyExists")); return; } } else if (_type == ConfirmType.Activation) { if (user.IsActive) { ShowError(Resource.ErrorConfirmURLError); return; } if (user.ID.Equals(ASC.Core.Users.Constants.LostUser.ID) || user.Status == EmployeeStatus.Terminated) { ShowError(string.Format(Resource.ErrorUserNotFoundByEmail, email)); return; } } if (!IsPostBack) { return; } var firstName = GetFirstName(); var lastName = GetLastName(); var pwd = (Request["pwdInput"] ?? "").Trim(); var repwd = (Request["repwdInput"] ?? "").Trim(); LoginProfile thirdPartyProfile; //thirdPartyLogin confirmInvite if (Request["__EVENTTARGET"] == "thirdPartyLogin") { var valueRequest = Request["__EVENTARGUMENT"]; thirdPartyProfile = new LoginProfile(valueRequest); if (!string.IsNullOrEmpty(thirdPartyProfile.AuthorizationError)) { // ignore cancellation if (thirdPartyProfile.AuthorizationError != "Canceled at provider") { ShowError(HttpUtility.HtmlEncode(thirdPartyProfile.AuthorizationError)); } return; } if (string.IsNullOrEmpty(thirdPartyProfile.EMail)) { ShowError(HttpUtility.HtmlEncode(Resource.ErrorNotCorrectEmail)); return; } } if (Request["__EVENTTARGET"] == "confirmInvite") { if (String.IsNullOrEmpty(email)) { _errorMessage = Resource.ErrorEmptyUserEmail; return; } if (!email.TestEmailRegex()) { _errorMessage = Resource.ErrorNotCorrectEmail; return; } if (String.IsNullOrEmpty(firstName)) { _errorMessage = Resource.ErrorEmptyUserFirstName; return; } if (String.IsNullOrEmpty(lastName)) { _errorMessage = Resource.ErrorEmptyUserLastName; return; } var checkPassResult = CheckPassword(pwd, repwd); if (!String.IsNullOrEmpty(checkPassResult)) { _errorMessage = checkPassResult; return; } } var userID = Guid.Empty; try { SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.CoreSystem); if (_type == ConfirmType.EmpInvite || _type == ConfirmType.LinkInvite) { if (TenantStatisticsProvider.GetUsersCount() >= TenantExtra.GetTenantQuota().ActiveUsers&& _employeeType == EmployeeType.User) { ShowError(UserControlsCommonResource.TariffUserLimitReason); return; } UserInfo newUser; if (Request["__EVENTTARGET"] == "confirmInvite") { var fromInviteLink = _type == ConfirmType.LinkInvite; newUser = CreateNewUser(firstName, lastName, email, pwd, _employeeType, fromInviteLink); userID = newUser.ID; } if (Request["__EVENTTARGET"] == "thirdPartyLogin") { if (!String.IsNullOrEmpty(CheckPassword(pwd, repwd))) { pwd = UserManagerWrapper.GeneratePassword(); } var valueRequest = Request["__EVENTARGUMENT"]; thirdPartyProfile = new LoginProfile(valueRequest); newUser = CreateNewUser(GetFirstName(thirdPartyProfile), GetLastName(thirdPartyProfile), GetEmailAddress(thirdPartyProfile), pwd, _employeeType, false); userID = newUser.ID; if (!String.IsNullOrEmpty(thirdPartyProfile.Avatar)) { SaveContactImage(userID, thirdPartyProfile.Avatar); } var linker = new AccountLinker("webstudio"); linker.AddLink(userID.ToString(), thirdPartyProfile); } } else if (_type == ConfirmType.Activation) { user.ActivationStatus = EmployeeActivationStatus.Activated; user.FirstName = firstName; user.LastName = lastName; CoreContext.UserManager.SaveUserInfo(user); SecurityContext.SetUserPassword(user.ID, pwd); userID = user.ID; //notify if (user.IsVisitor()) { StudioNotifyService.Instance.GuestInfoAddedAfterInvite(user, pwd); } else { StudioNotifyService.Instance.UserInfoAddedAfterInvite(user, pwd); } } } catch (Exception exception) { _errorMessage = HttpUtility.HtmlEncode(exception.Message); return; } finally { SecurityContext.Logout(); } try { var cookiesKey = SecurityContext.AuthenticateMe(userID.ToString(), pwd); CookiesManager.SetCookies(CookiesType.UserID, userID.ToString()); CookiesManager.SetCookies(CookiesType.AuthKey, cookiesKey); StudioNotifyService.Instance.UserHasJoin(); } catch (Exception exception) { (Page as confirm).ErrorMessage = HttpUtility.HtmlEncode(exception.Message); return; } user = CoreContext.UserManager.GetUsers(userID); UserHelpTourHelper.IsNewUser = true; Response.Redirect(user.IsVisitor() ? "~/" : "~/welcome.aspx"); }
protected void Page_Load(object sender, EventArgs e) { Page.Title = HeaderStringHelper.GetPageTitle(Resource.AccountControlPageTitle); Master.DisabledSidePanel = true; Master.TopStudioPanel.DisableProductNavigation = true; Master.TopStudioPanel.DisableUserInfo = true; Master.TopStudioPanel.DisableSearch = true; Master.TopStudioPanel.DisableSettings = true; Master.TopStudioPanel.DisableVideo = true; _tenantInfoSettings = SettingsManager.Instance.LoadSettings <TenantInfoSettings>(TenantProvider.CurrentTenantID); var email = Request["email"] ?? ""; var key = Request["key"] ?? ""; var emplType = Request["emplType"] ?? ""; var type = typeof(ConfirmType).TryParseEnum(Request["type"] ?? "", ConfirmType.EmpInvite); var validInterval = SetupInfo.ValidEamilKeyInterval; var authInterval = TimeSpan.FromHours(1); EmailValidationKeyProvider.ValidationResult checkKeyResult; UserInfo user = null; var tenant = CoreContext.TenantManager.GetCurrentTenant(); if (tenant.Status != TenantStatus.Active && type != ConfirmType.PortalContinue) { Response.Redirect(SetupInfo.NoTenantRedirectURL, true); } if (type == ConfirmType.DnsChange) { var dnsChangeKey = string.Join(string.Empty, new[] { email, type.ToString(), Request["dns"], Request["alias"] }); checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(dnsChangeKey, key, validInterval); } else if (type == ConfirmType.PortalContinue) { checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString(), key); } else if ((type == ConfirmType.EmpInvite || type == ConfirmType.Activation) && !String.IsNullOrEmpty(emplType)) { checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString() + emplType, key, validInterval); } else if (type == ConfirmType.PasswordChange) { //Check activation signature checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString(), key, validInterval); } else if (type == ConfirmType.PortalOwnerChange && !String.IsNullOrEmpty(Request["uid"])) { var uid = Guid.Empty; try { uid = new Guid(Request["uid"]); } catch { } checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString() + uid.ToString(), key, validInterval); } else if (type == ConfirmType.ProfileRemove && !(String.IsNullOrEmpty(Request["email"]) || String.IsNullOrEmpty(Request["key"]))) { user = CoreContext.UserManager.GetUserByEmail(email); if (user.ID.Equals(Constants.LostUser.ID)) { ShowError(Resource.ErrorUserNotFound); return; } checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString(), key, validInterval); } else if (type == ConfirmType.EmpInvite && String.IsNullOrEmpty(email)) { checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString(), key, TimeSpan.FromDays(3)); } else if (type == ConfirmType.PhoneAuth || type == ConfirmType.PhoneActivation) { checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString(), key, authInterval); } else if (type == ConfirmType.Auth) { if (SecurityContext.IsAuthenticated) { Response.Redirect(CommonLinkUtility.GetDefault()); } checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString(), key, authInterval); if (checkKeyResult == EmailValidationKeyProvider.ValidationResult.Ok) { user = CoreContext.UserManager.GetUserByEmail(email); var authCookie = SecurityContext.AuthenticateMe(user.ID); CookiesManager.SetCookies(CookiesType.AuthKey, authCookie); Response.Redirect(CommonLinkUtility.GetDefault()); return; } } else { checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString() + emplType, key, validInterval); } if (type == ConfirmType.PhoneActivation && SecurityContext.IsAuthenticated) { Master.TopStudioPanel.DisableUserInfo = false; } if ((!email.TestEmailRegex() || checkKeyResult != EmailValidationKeyProvider.ValidationResult.Ok) && type != ConfirmType.LinkInvite) { ShowError(Resource.ErrorConfirmURLError); return; } if (!email.TestEmailRegex() && type != ConfirmType.LinkInvite) { ShowError(Resource.ErrorNotCorrectEmail); return; } if (checkKeyResult == EmailValidationKeyProvider.ValidationResult.Invalid) { //If check failed ShowError(Resource.ErrorInvalidActivationLink); return; } if (checkKeyResult == EmailValidationKeyProvider.ValidationResult.Expired) { //If link expired ShowError(Resource.ErrorExpiredActivationLink); return; } switch (type) { //Invite case ConfirmType.EmpInvite: case ConfirmType.LinkInvite: case ConfirmType.Activation: _confirmHolder2.Controls.Add(LoadControl(ConfirmInviteActivation.Location)); _contentWithControl.Visible = false; break; case ConfirmType.EmailChange: case ConfirmType.PasswordChange: _confirmHolder.Controls.Add(LoadControl(ConfirmActivation.Location)); break; case ConfirmType.EmailActivation: ProcessEmailActivation(email); break; case ConfirmType.PortalRemove: case ConfirmType.PortalSuspend: case ConfirmType.PortalContinue: case ConfirmType.DnsChange: _confirmHolder.Controls.Add(LoadControl(ConfirmPortalActivity.Location)); break; case ConfirmType.PortalOwnerChange: _confirmHolder.Controls.Add(LoadControl(ConfirmPortalOwner.Location)); break; case ConfirmType.ProfileRemove: var control = (ProfileOperation)LoadControl(ProfileOperation.Location); control.Key = key; control.Email = email; control.User = user; _confirmHolder.Controls.Add(control); break; case ConfirmType.PhoneActivation: case ConfirmType.PhoneAuth: var confirmMobileActivation = (ConfirmMobileActivation)LoadControl(ConfirmMobileActivation.Location); confirmMobileActivation.Activation = type == ConfirmType.PhoneActivation; confirmMobileActivation.User = CoreContext.UserManager.GetUserByEmail(email); _confirmHolder.Controls.Add(confirmMobileActivation); break; } }
public static void ApplyPartnerWhiteLableSettings() { if (!TenantExtra.Enterprise && !TenantExtra.Hosted) { return; } var firstVisit = CompanyWhiteLabelSettings.Instance.IsDefault && AdditionalWhiteLabelSettings.Instance.IsDefault && MailWhiteLabelSettings.Instance.IsDefault; try { var partnerdataStorage = StorageFactory.GetStorage(string.Empty, "static_partnerdata"); if (partnerdataStorage == null) { return; } if (!partnerdataStorage.IsFile(JsonDataFilePath)) { return; } var stream = partnerdataStorage.GetReadStream(JsonDataFilePath); JObject jsonObject; using (var reader = new StreamReader(stream)) { jsonObject = JObject.Parse(reader.ReadToEnd()); } if (jsonObject == null) { return; } var companySettings = JsonConvert.DeserializeObject <CompanyWhiteLabelSettings>(jsonObject["CompanyWhiteLabelSettings"].ToString()); var additionalSettings = JsonConvert.DeserializeObject <AdditionalWhiteLabelSettings>(jsonObject["AdditionalWhiteLabelSettings"].ToString()); var mailSettings = JsonConvert.DeserializeObject <MailWhiteLabelSettings>(jsonObject["MailWhiteLabelSettings"].ToString()); var tenantSettings = JsonConvert.DeserializeObject <TenantWhiteLabelSettings>(jsonObject["TenantWhiteLabelSettings"].ToString()); var smtpSettingsStr = jsonObject["SmtpSettings"].ToString(); var defaultCultureName = jsonObject["DefaultCulture"].ToString(); companySettings.SaveForDefaultTenant(); additionalSettings.SaveForDefaultTenant(); mailSettings.SaveForDefaultTenant(); tenantSettings.SaveForDefaultTenant(); if (!String.IsNullOrEmpty(smtpSettingsStr)) { try { SmtpSettings.Deserialize(smtpSettingsStr); // try deserialize SmtpSettings object CoreContext.Configuration.SaveSetting("SmtpSettings", smtpSettingsStr); } catch (Exception e) { Log.Error(e.Message, e); } } if (!String.IsNullOrEmpty(defaultCultureName)) { var defaultCulture = CultureInfo.GetCultureInfo(defaultCultureName); if (SetupInfo.EnabledCultures.Find(culture => String.Equals(culture.Name, defaultCulture.Name, StringComparison.InvariantCultureIgnoreCase)) != null) { var tenant = CoreContext.TenantManager.GetCurrentTenant(); tenant.Language = defaultCulture.Name; CoreContext.TenantManager.SaveTenant(tenant); } } var logoImages = partnerdataStorage.ListFiles(String.Empty, LogoPattern, false); if (!logoImages.Any()) { MakeLogoFiles(partnerdataStorage, jsonObject); } if (!firstVisit) { return; } var tenantInfoSettings = TenantInfoSettings.Load(); tenantInfoSettings.RestoreDefaultTenantName(); } catch (Exception e) { Log.Error(e.Message, e); } }
protected void Page_Load(object sender, EventArgs e) { ((IStudioMaster)this.Master).DisabledSidePanel = true; UserInfo _user = null; this.Page.Title = HeaderStringHelper.GetPageTitle(Resources.Resource.AccountControlPageTitle, null, null); var type = typeof(ConfirmType).TryParseEnum <ConfirmType>(Request["type"] ?? "", ConfirmType.EmpInvite); ((StudioTemplate)this.Master).TopNavigationPanel.DisableProductNavigation = true; ((StudioTemplate)this.Master).TopNavigationPanel.DisableUserInfo = true; ((StudioTemplate)this.Master).TopNavigationPanel.DisableSearch = true; if (type == ConfirmType.Activation || type == ConfirmType.EmpInvite) { ((StudioTemplate)this.Master).TopNavigationPanel.CustomTitle = Resources.Resource.JoinTitle; } _tenantInfoSettings = SettingsManager.Instance.LoadSettings <TenantInfoSettings>(TenantProvider.CurrentTenantID); var email = Request["email"] ?? ""; var key = Request["key"] ?? ""; var fap = Request["fap"] ?? ""; var validInterval = SetupInfo.ValidEamilKeyInterval; var checkKeyResult = EmailValidationKeyProvider.ValidationResult.Invalid; var tenant = CoreContext.TenantManager.GetCurrentTenant(); if (tenant.Status != TenantStatus.Active && type != ConfirmType.PortalContinue) { Response.Redirect(SetupInfo.NoTenantRedirectURL, true); } if (type == ConfirmType.DnsChange) { var dnsChangeKey = string.Join(string.Empty, new string[] { email.ToLower(), type.ToString().ToLower(), Request["dns"], Request["alias"] }); checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(dnsChangeKey, key, validInterval); } else if (type == ConfirmType.PortalContinue) { checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString().ToLower(), key); } else if ((type == ConfirmType.EmpInvite || type == ConfirmType.Activation) && !String.IsNullOrEmpty(fap) && String.Equals(fap, "1")) { checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString().ToLower() + "allrights", key, validInterval); } else if (type == ConfirmType.PasswordChange) { //Check activation signature checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString().ToLower(), key, validInterval); } else if (type == ConfirmType.PortalOwnerChange && !String.IsNullOrEmpty(Request["uid"])) { Guid uid = Guid.Empty; try { uid = new Guid(Request["uid"]); } catch { } checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString().ToLower() + uid.ToString(), key, validInterval); } else if (type == ConfirmType.ProfileRemove && !(String.IsNullOrEmpty(Request["email"]) || String.IsNullOrEmpty(Request["key"]))) { _user = CoreContext.UserManager.GetUserByEmail(email); if (_user.ID.Equals(ASC.Core.Users.Constants.LostUser.ID)) { return; } checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString().ToLower(), key, validInterval); } else if (type == ConfirmType.EmpInvite && String.IsNullOrEmpty(email)) { checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString().ToLower(), key, TimeSpan.FromDays(3)); } else if (type == ConfirmType.PhoneActivation || type == ConfirmType.PhoneAuth) { UserTransferData obj; if (Context.Session["UserTransferData"] != null) { obj = (Context.Session["UserTransferData"] as UserTransferData); key = obj.ValidationKey; } else { obj = new UserTransferData { Login = email }; } checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey((obj.HashId ?? obj.Login) + type.ToString().ToLower(), key, TimeSpan.FromDays(3)); } else if (type == ConfirmType.PhoneChange) { checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString().ToLower(), key, TimeSpan.FromDays(3)); } else { checkKeyResult = EmailValidationKeyProvider.ValidateEmailKey(email + type.ToString().ToLower(), key, validInterval); } if (((!email.TestEmailRegex() && !(type == ConfirmType.PhoneActivation || type == ConfirmType.PhoneAuth)) || checkKeyResult != EmailValidationKeyProvider.ValidationResult.Ok) && type != ConfirmType.LinkInvite) { ShowError(Resources.Resource.ErrorConfirmURLError); return; } if (!email.TestEmailRegex() && !(type == ConfirmType.LinkInvite || type == ConfirmType.PhoneActivation || type == ConfirmType.PhoneAuth)) { ShowError(Resources.Resource.ErrorNotCorrectEmail); return; } if (checkKeyResult == EmailValidationKeyProvider.ValidationResult.Invalid) { //If check failed ShowError(Resources.Resource.ErrorInvalidActivationLink); return; } if (checkKeyResult == EmailValidationKeyProvider.ValidationResult.Expired) { //If link expired ShowError(Resources.Resource.ErrorExpiredActivationLink); return; } switch (type) { //Invite case ConfirmType.EmpInvite: case ConfirmType.LinkInvite: case ConfirmType.Activation: _confirmHolder2.Controls.Add(LoadControl(ConfirmInviteActivation.Location)); _contentWithControl.Visible = false; break; case ConfirmType.EmailChange: case ConfirmType.PasswordChange: _confirmHolder.Controls.Add(LoadControl(ConfirmActivation.Location)); break; case ConfirmType.EmailActivation: ProcessEmailActivation(email); break; case ConfirmType.PortalRemove: case ConfirmType.PortalSuspend: case ConfirmType.PortalContinue: case ConfirmType.DnsChange: _confirmHolder.Controls.Add(LoadControl(ConfirmPortalActivity.Location)); break; case ConfirmType.PortalOwnerChange: _confirmHolder.Controls.Add(LoadControl(ConfirmPortalOwner.Location)); break; case ConfirmType.ProfileRemove: var control = (ProfileOperation)LoadControl(ProfileOperation.Location); control.Key = key; control.Email = email; control.User = _user; _confirmHolder.Controls.Add(control); break; case ConfirmType.PhoneActivation: case ConfirmType.PhoneChange: var authControl = (ConfirmMobileActivation)LoadControl(ConfirmMobileActivation.Location); authControl.Activate = true; _confirmHolder.Controls.Add(authControl); break; case ConfirmType.PhoneAuth: var authControl1 = (ConfirmMobileActivation)LoadControl(ConfirmMobileActivation.Location); authControl1.Activate = false; _confirmHolder.Controls.Add(authControl1); break; } }
public object RestoreGreetingLogoSettings() { try { SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings); _tenantInfoSettings = SettingsManager.Instance.LoadSettings<TenantInfoSettings>(TenantProvider.CurrentTenantID); _tenantInfoSettings.RestoreDefault(); SettingsManager.Instance.SaveSettings(_tenantInfoSettings, TenantProvider.CurrentTenantID); if (TenantLogoManager.CoBrandingEnabled) { var _tenantCoBrandingSettings = SettingsManager.Instance.LoadSettings<TenantCoBrandingSettings>(TenantProvider.CurrentTenantID); _tenantCoBrandingSettings.RestoreDefault(CoBrandingLogoTypeEnum.Dark); SettingsManager.Instance.SaveSettings(_tenantCoBrandingSettings, TenantProvider.CurrentTenantID); } return new { Status = 1, Message = Resource.SuccessfullySaveGreetingSettingsMessage, LogoPath = _tenantInfoSettings.GetAbsoluteCompanyLogoPath() }; } catch (Exception e) { return new { Status = 0, Message = e.Message.HtmlEncode() }; } }
protected void Page_Load(object sender, EventArgs e) { Page.Title = HeaderStringHelper.GetPageTitle(Resource.AccountControlPageTitle); Master.DisabledSidePanel = true; Master.TopStudioPanel.DisableProductNavigation = true; Master.TopStudioPanel.DisableUserInfo = true; Master.TopStudioPanel.DisableSearch = true; Master.TopStudioPanel.DisableSettings = true; Master.TopStudioPanel.DisableTariff = true; Master.TopStudioPanel.DisableLoginPersonal = true; _tenantInfoSettings = SettingsManager.Instance.LoadSettings<TenantInfoSettings>(TenantProvider.CurrentTenantID); _email = Request["email"] ?? ""; var tenant = CoreContext.TenantManager.GetCurrentTenant(); if (tenant.Status != TenantStatus.Active && _type != ConfirmType.PortalContinue) { Response.Redirect(SetupInfo.NoTenantRedirectURL, true); } if (_type == ConfirmType.PhoneActivation && SecurityContext.IsAuthenticated) { Master.TopStudioPanel.DisableUserInfo = false; } else { Master.DisabledTopStudioPanel = true; } if (!CheckValidationKey()) { return; } LoadControls(); }
protected void Page_Load(object sender, EventArgs e) { _login = ""; _password = ""; //Account link control AccountLinkControl accountLink = null; if (SetupInfo.ThirdPartyAuthEnabled) { accountLink = (AccountLinkControl)LoadControl(AccountLinkControl.Location); associateAccount.Visible = true; associateAccount.Text = Resources.Resource.LoginWithAccount; accountLink.ClientCallback = "authCallback"; accountLink.SettingsView = false; signInPlaceholder.Controls.Add(accountLink); } ((IStudioMaster)this.Master).DisabledSidePanel = true; //top panel if (this.Master is StudioTemplate) { ((StudioTemplate)this.Master).TopNavigationPanel.DisableProductNavigation = true; ((StudioTemplate)this.Master).TopNavigationPanel.DisableSearch = true; } _tenantInfoSettings = SettingsManager.Instance.LoadSettings <TenantInfoSettings>(TenantProvider.CurrentTenantID); this.Title = HeaderStringHelper.GetPageTitle(Resources.Resource.Authorization, null, null); pwdReminderHolder.Controls.Add(LoadControl(PwdTool.Location)); pwdReminderHolder.Controls.Add(LoadControl(InviteEmployeeControl.Location)); _communitations.Controls.Add(LoadControl(AuthCommunications.Location)); var msg = Request["m"]; if (!string.IsNullOrEmpty(msg)) { _loginMessage = "<div class='errorBox'>" + HttpUtility.HtmlEncode(msg) + "</div>"; } if (this.IsPostBack && !SecurityContext.IsAuthenticated) { var uData = new UserTransferData(); if (!String.IsNullOrEmpty(Request["login"])) { _login = Request["login"]; uData.Login = _login; } if (!String.IsNullOrEmpty(Request["pwd"])) { _password = Request["pwd"]; uData.Password = _password; } bool isDemo = false; if (!String.IsNullOrEmpty(Request["authtype"])) { isDemo = Request["authtype"] == "demo"; } string hashId = string.Empty; if (!string.IsNullOrEmpty(Request["__EVENTARGUMENT"]) && Request["__EVENTTARGET"] == "signInLogin" && accountLink != null) { //Login from open id hashId = Request["__EVENTARGUMENT"]; uData.HashId = hashId; } if (isDemo) { SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.Demo); } else { try { string cookiesKey = string.Empty; if (!string.IsNullOrEmpty(hashId)) { var accounts = accountLink.GetLinker().GetLinkedObjectsByHashId(hashId); foreach (var account in accounts.Select(x => { try { return(new Guid(x)); } catch { return(Guid.Empty); } })) { if (CoreContext.UserManager.UserExists(account) && account != Guid.Empty) { var coreAcc = CoreContext.UserManager.GetUsers(account); cookiesKey = SecurityContext.AuthenticateMe(coreAcc.Email, CoreContext.Authentication.GetUserPasswordHash(coreAcc.ID)); uData.UserId = coreAcc.ID; ProcessSmsValidation(uData); } } if (string.IsNullOrEmpty(cookiesKey)) { _loginMessage = "<div class=\"errorBox\">" + HttpUtility.HtmlEncode(Resources.Resource.LoginWithAccountNotFound) + "</div>"; return; } } else { cookiesKey = SecurityContext.AuthenticateMe(_login, _password); uData.UserId = SecurityContext.CurrentAccount.ID; ProcessSmsValidation(uData); } CookiesManager.SetCookies(CookiesType.AuthKey, cookiesKey); } catch (System.Security.SecurityException) { ProcessLogout(); _loginMessage = "<div class=\"errorBox\">" + HttpUtility.HtmlEncode(Resources.Resource.InvalidUsernameOrPassword) + "</div>"; return; } catch (Exception exception) { ProcessLogout(); _loginMessage = "<div class=\"errorBox\">" + HttpUtility.HtmlEncode(exception.Message) + "</div>"; return; } } UserOnlineManager.Instance.RegistryOnlineUser(SecurityContext.CurrentAccount.ID); WebItemManager.Instance.ItemGlobalHandlers.Login(SecurityContext.CurrentAccount.ID); string refererURL = (string)Session["refererURL"]; if (String.IsNullOrEmpty(refererURL)) { Response.Redirect("~/"); } else { Session["refererURL"] = null; Response.Redirect(refererURL); } return; } else if (SecurityContext.IsAuthenticated && base.IsLogout) { ProcessLogout(); Response.Redirect("~/auth.aspx"); } ProcessConfirmedEmailCondition(); }
protected override void OnInit(EventArgs e) { Page.ClientScript.RegisterClientScriptInclude(typeof(string), "ajaxupload_script", WebPath.GetPath("js/ajaxupload.3.5.js")); TenantInfoSettings = SettingsManager.Instance.LoadSettings <TenantInfoSettings>(TenantProvider.CurrentTenantID); }
protected void Page_Load(object sender, EventArgs e) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "confirm_invite_activation_style", "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + WebSkin.GetUserSkin().GetAbsoluteWebPath("usercontrols/management/confirminviteactivation/css/<theme_folder>/confirm_invite_activation.css") + "\">", false); Page.ClientScript.RegisterClientScriptInclude(typeof(string), "confirm_invite_activation_script", WebPath.GetPath("usercontrols/management/confirminviteactivation/js/confirm_invite_activation.js")); _tenantInfoSettings = SettingsManager.Instance.LoadSettings <TenantInfoSettings>(TenantProvider.CurrentTenantID); Guid uid = Guid.Empty; try { uid = new Guid(Request["uid"]); } catch { } var type = typeof(ConfirmType).TryParseEnum(Request["type"] ?? "", ConfirmType.EmpInvite); var email = GetEmailAddress(); var key = Request["key"] ?? ""; var fap = Request["fap"] ?? ""; //if (!string.IsNullOrEmpty(_email)) //{ //var thrd = LoadControl(AccountLinkControl.Location) as AccountLinkControl; //thrd.InviteView = true; //thrd.ClientCallback = "loginJoinCallback"; //thrdParty.Controls.Add(thrd); //} Page.Title = HeaderStringHelper.GetPageTitle(Resources.Resource.Authorization, null, null); UserInfo user; try { SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.CoreSystem); user = CoreContext.UserManager.GetUserByEmail(email); var usr = CoreContext.UserManager.GetUsers(uid); if (usr.ID.Equals(ASC.Core.Users.Constants.LostUser.ID) || usr.ID.Equals(ASC.Core.Configuration.Constants.Guest.ID)) { usr = CoreContext.UserManager.GetUsers(CoreContext.TenantManager.GetCurrentTenant().OwnerId); } _userAvatar = usr.GetMediumPhotoURL(); _userName = usr.DisplayUserName(true); _userPost = (usr.Title ?? "").HtmlEncode(); } finally { SecurityContext.Logout(); } if (type == ConfirmType.LinkInvite || type == ConfirmType.EmpInvite) { if (!user.ID.Equals(ASC.Core.Users.Constants.LostUser.ID)) { ShowError(CustomNamingPeople.Substitute <Resources.Resource>("ErrorEmailAlreadyExists")); return; } } else if (type == ConfirmType.Activation) { if (user.IsActive) { ShowError(Resources.Resource.ErrorConfirmURLError); return; } if (user.ID.Equals(ASC.Core.Users.Constants.LostUser.ID)) { ShowError(string.Format(Resources.Resource.ErrorUserNotFoundByEmail, email)); return; } } if (!IsPostBack) { return; } var firstName = GetFirstName(); var lastName = GetLastName(); var pwd = (Request["pwdInput"] ?? "").Trim(); var repwd = (Request["repwdInput"] ?? "").Trim(); LoginProfile thirdPartyProfile; //thirdPartyLogin confirmInvite if (Request["__EVENTTARGET"] == "thirdPartyLogin") { var valueRequest = Request["__EVENTARGUMENT"]; thirdPartyProfile = new LoginProfile(valueRequest); if (!string.IsNullOrEmpty(thirdPartyProfile.AuthorizationError)) { // ignore cancellation if (thirdPartyProfile.AuthorizationError != "Canceled at provider") { ShowError(HttpUtility.HtmlEncode(thirdPartyProfile.AuthorizationError)); } return; } if (string.IsNullOrEmpty(thirdPartyProfile.EMail)) { ShowError(HttpUtility.HtmlEncode(Resources.Resource.ErrorNotCorrectEmail)); return; } } if (Request["__EVENTTARGET"] == "confirmInvite") { if (String.IsNullOrEmpty(email)) { _errorMessage = Resources.Resource.ErrorEmptyUserEmail; return; } if (!email.TestEmailRegex()) { _errorMessage = Resources.Resource.ErrorNotCorrectEmail; return; } if (String.IsNullOrEmpty(firstName)) { _errorMessage = Resources.Resource.ErrorEmptyUserFirstName; return; } if (String.IsNullOrEmpty(lastName)) { _errorMessage = Resources.Resource.ErrorEmptyUserLastName; return; } var checkPassResult = CheckPassword(pwd, repwd); if (!String.IsNullOrEmpty(checkPassResult)) { _errorMessage = checkPassResult; return; } } var userID = Guid.Empty; try { SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.CoreSystem); if (type == ConfirmType.EmpInvite || type == ConfirmType.LinkInvite) { UserInfo newUser; if (Request["__EVENTTARGET"] == "confirmInvite") { newUser = CreateNewUser(firstName, lastName, email, pwd); userID = newUser.ID; } if (Request["__EVENTTARGET"] == "thirdPartyLogin") { if (!String.IsNullOrEmpty(CheckPassword(pwd, repwd))) { pwd = UserManagerWrapper.GeneratePassword(); } var valueRequest = Request["__EVENTARGUMENT"]; thirdPartyProfile = new LoginProfile(valueRequest); newUser = CreateNewUser(GetFirstName(thirdPartyProfile), GetLastName(thirdPartyProfile), GetEmailAddress(thirdPartyProfile), pwd); userID = newUser.ID; var linker = new AccountLinker(WebConfigurationManager.ConnectionStrings["webstudio"]); linker.AddLink(userID.ToString(), thirdPartyProfile); } #region Department try { var deptID = new Guid((Request["deptID"] ?? "").Trim()); CoreContext.UserManager.AddUserIntoGroup(userID, deptID); } catch { } #endregion } else if (type == ConfirmType.Activation) { user.ActivationStatus = EmployeeActivationStatus.Activated; user.FirstName = firstName; user.LastName = lastName; CoreContext.UserManager.SaveUserInfo(user); SecurityContext.SetUserPassword(user.ID, pwd); userID = user.ID; //notify StudioNotifyService.Instance.UserInfoAddedAfterInvite(user, pwd); } if (String.Equals(fap, "1")) { CoreContext.UserManager.AddUserIntoGroup(userID, ASC.Core.Users.Constants.GroupAdmin.ID); } } catch (Exception exception) { (Page as confirm).ErrorMessage = HttpUtility.HtmlEncode(exception.Message); return; } finally { SecurityContext.Logout(); } try { var cookiesKey = SecurityContext.AuthenticateMe(userID.ToString(), pwd); CookiesManager.SetCookies(CookiesType.UserID, userID.ToString()); CookiesManager.SetCookies(CookiesType.AuthKey, cookiesKey); StudioNotifyService.Instance.UserHasJoin(); } catch (Exception exception) { (Page as confirm).ErrorMessage = HttpUtility.HtmlEncode(exception.Message); return; } UserOnlineManager.Instance.RegistryOnlineUser(SecurityContext.CurrentAccount.ID); WebItemManager.Instance.ItemGlobalHandlers.Login(SecurityContext.CurrentAccount.ID); var smsAuthSettings = SettingsManager.Instance.LoadSettings <StudioSmsNotificationSettings>(TenantProvider.CurrentTenantID); if (smsAuthSettings.Enable) { var uData = new UserTransferData(); var usr = CoreContext.UserManager.GetUsers(userID); uData.Login = usr.Email; uData.UserId = userID; Session["UserTransferData"] = uData; } Response.Redirect("~/"); }