private string Authenticate(UserTransferData obj) { if (!String.IsNullOrEmpty(obj.HashId)) { return(AuthenticateByHash(obj.HashId)); } return(AuthenticateByPair(obj.Login, obj.Password)); }
private void ProcessSmsValidation(UserTransferData uData) { var smsAuthSettings = SettingsManager.Instance.LoadSettings <StudioSmsNotificationSettings>(TenantProvider.CurrentTenantID); if (smsAuthSettings.Enable && SetupInfo.IsVisibleSettings <StudioSmsNotificationSettings>()) { var confKey = CookiesManager.GetCookies(CookiesType.ConfKey); var activated = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).MobilePhoneActivationStatus; if (!String.IsNullOrEmpty(confKey) && EmailValidationKeyProvider.ValidateEmailKey(CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).Email, confKey, TimeSpan.FromDays(30)) == EmailValidationKeyProvider.ValidationResult.Ok) { return; } uData.MobilePhoneActivationStatus = activated; uData.ValidationKey = EmailValidationKeyProvider.GetEmailKey(GetEmailKey(uData, activated)); Session["UserTransferData"] = uData; ProcessLogout(); Response.Redirect(String.Format("~/Confirm.aspx?type={0}", activated == MobilePhoneActivationStatus.Activated ? ConfirmType.PhoneAuth : ConfirmType.PhoneActivation)); } }
private string Authenticate(UserTransferData obj) { if (!String.IsNullOrEmpty(obj.HashId)) return AuthenticateByHash(obj.HashId); return AuthenticateByPair(obj.Login, obj.Password); }
private UserInfo GetUser(UserTransferData obj) { return CoreContext.UserManager.GetUsers(obj == null ? SecurityContext.CurrentAccount.ID : (!String.IsNullOrEmpty(obj.HashId) ? GetUserGuid(obj.HashId) : obj.UserId)); }
void PutAuthCode(UserTransferData obj, string phoneNumber, bool again) { if (phoneNumber.StartsWith("+")) phoneNumber = phoneNumber.Substring(1, phoneNumber.Length - 1); if (obj == null || obj.MobilePhoneActivationStatus == MobilePhoneActivationStatus.NotActivated) { var user = GetUser(obj); user.MobilePhone = phoneNumber; user.MobilePhoneActivationStatus = 0; if (obj != null) Authenticate(obj); CoreContext.UserManager.SaveUserInfo(user); if (obj != null) SecurityContext.Logout(); } if (String.IsNullOrEmpty(StudioSmsKeyStorage.Instance.GetKey(phoneNumber)) || again) { SendMessageToLogon(phoneNumber); } }
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; } }
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; } }
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(); }
private string GetEmailKey(UserTransferData uData, MobilePhoneActivationStatus activated) { return((uData.HashId ?? uData.Login) + (activated == MobilePhoneActivationStatus.Activated ? ConfirmType.PhoneAuth : ConfirmType.PhoneActivation).ToString().ToLower()); }
private UserInfo GetUser(UserTransferData obj) { return(CoreContext.UserManager.GetUsers(obj == null ? SecurityContext.CurrentAccount.ID : (!String.IsNullOrEmpty(obj.HashId) ? GetUserGuid(obj.HashId) : obj.UserId))); }
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("~/"); }
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("~/"); }