/// <summary> /// Handles the Click event of the LoginBtn control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> /// <remarks></remarks> private void LoginBtnClick(object sender, EventArgs e) { this.Session["PersistedUser"] = this.RememberCheckBox.Checked; int timeout = Convert.ToInt32(ConfigurationManager.AppSettings["RememberMe.Session.TimeOut"]); //HttpCookie myCookie = new HttpCookie("MyTestCookie"); //DateTime now = DateTime.Now; if (RememberCheckBox.Checked) { Response.Cookies["email"].Value = email.Text; Response.Cookies["password"].Value = password.Text; Response.Cookies["email"].Expires = DateTime.MaxValue; Response.Cookies["password"].Expires = DateTime.MaxValue; } else { Response.Cookies["email"].Expires = DateTime.Now.AddDays(timeout); Response.Cookies["password"].Expires = DateTime.Now.AddDays(timeout); } if (PortalSecurity.SignOn(this.email.Text.Trim(), this.password.Text, this.RememberCheckBox.Checked) == null) { this.Message.Text = Appleseed.Signin_LoginBtnClick_Login_failed; this.Message.TextKey = "LOGIN_FAILED"; //Get Failed Password Attampt Counter //e.g. ((AppleseedUser)((AppleseedMembershipProvider)System.Web.Security.Membership.Provider).GetUser(PortalSettings.PortalAlias, email.Text, true)).FailedPasswordAttemptCount } }
/// <summary> /// Handles the Click event of the SaveChangesBtn control. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="System.EventArgs"/> instance containing the event data. /// </param> protected void SaveChangesBtnClick(object sender, EventArgs e) { this.Page.Validate(); if (this.Page.IsValid) { var returnId = this.SaveUserData(); if (returnId == Guid.Empty) { if (this.SelfEdit) { // All should be ok now // Try logoff user PortalSecurity.SignOut(string.Empty, true); // Logon user again with new settings var actualPassword = this.PasswordField.Text.Length != 0 ? this.PasswordField.Text : this.OriginalPassword; // Full signon PortalSecurity.SignOn(this.EmailField.Text, actualPassword, false, this.RedirectPage); } else if (this.RedirectPage == string.Empty) { // Redirect browser back to home page PortalSecurity.PortalHome(); } else { this.Response.Redirect(this.RedirectPage); } } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { string user = Request.Params["u"]; string pass = Request.Params["p"]; string lnkid = Request.QueryString["lnkid"]; if (!string.IsNullOrEmpty(lnkid)) { int pageId = 0; if (int.TryParse(lnkid, out pageId)) { var ps = Framework.Site.Configuration.PortalSettings.GetPortalSettings(pageId, this.PortalSettings.PortalAlias); string redirectUrl = string.Empty; if (ps.ActivePage.Settings["TabLink"] != null && !string.IsNullOrEmpty(ps.ActivePage.Settings["TabLink"].ToString())) { redirectUrl = ps.ActivePage.Settings["TabLink"].ToString(); } else if (ps.ActivePage.CustomSettings["TabLink"] != null && !string.IsNullOrEmpty(ps.ActivePage.CustomSettings["TabLink"].ToString())) { redirectUrl = ps.ActivePage.CustomSettings["TabLink"].ToString(); } this.Response.Redirect(redirectUrl, true); } } if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(pass)) { bool rem = (Request.Params["rem"] ?? "0").ToString().Equals("1") ? true : false; PortalSecurity.SignOn(user, pass, rem, "~/DesktopDefault.aspx"); //PortalSecurity.SignOn(user, pass, false, "~/DesktopDefault.aspx"); } Server.Transfer("DesktopDefault.aspx", true); }
private void LoginBtn_Click(Object sender, System.EventArgs e) { if (PortalSecurity.SignOn(email.Text, password.Text, RememberCheckBox.Checked) == null) { Message.Text = "Login failed"; Message.TextKey = "LOGIN_FAILED"; } }
/// <summary> /// Handles the Click event of the LoginBtn control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> /// <remarks></remarks> private void LoginBtnClick(object sender, EventArgs e) { this.Session["PersistedUser"] = this.RememberCheckBox.Checked; if (PortalSecurity.SignOn(this.email.Text.Trim(), this.password.Text, this.RememberCheckBox.Checked) == null) { this.Message.Text = Appleseed.Signin_LoginBtnClick_Login_failed; this.Message.TextKey = "LOGIN_FAILED"; } }
/// <summary> /// Handles the Click event of the LoginBtn control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void LoginBtn_Click(Object sender, EventArgs e) { if (PortalSecurity.SignOn(email.Text, password.Text, RememberCheckBox.Checked, Request.QueryString["ReturnUrl"]) == null) { Message.Text = "Login failed"; Message.TextKey = "LOGIN_FAILED"; //Get Failed Password Attampt Counter //e.g. ((AppleseedUser)((AppleseedMembershipProvider)System.Web.Security.Membership.Provider).GetUser(PortalSettings.PortalAlias, email.Text, true)).FailedPasswordAttemptCount } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { string user = Request.Params["u"]; string pass = Request.Params["p"]; if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(pass)) { bool rem = (Request.Params["rem"] ?? "0").ToString().Equals("1") ? true : false; PortalSecurity.SignOn(user, pass, rem, "~/DesktopDefault.aspx"); //PortalSecurity.SignOn(user, pass, false, "~/DesktopDefault.aspx"); } Server.Transfer("DesktopDefault.aspx", true); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void RegisterBtn_Click(object sender, EventArgs e) { Guid returnID = SaveUserData(); if (returnID != Guid.Empty) { if (portalSettings.CustomSettings["SITESETTINGS_ON_REGISTER_SEND_TO"].ToString().Length > 0) { SendRegistrationNoticeToAdmin(); } //Full signon PortalSecurity.SignOn(EmailField.Text, PasswordField.Text, false, RedirectPage); } }
/// <summary> /// Handles the Click event of the RegisterBtn control. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="System.EventArgs"/> instance containing the event data. /// </param> protected void RegisterBtnClick(object sender, EventArgs e) { var returnId = this.SaveUserData(); if (returnId == Guid.Empty) { return; } if (this.PortalSettings.CustomSettings["SITESETTINGS_ON_REGISTER_SEND_TO"].ToString().Length > 0) { this.SendRegistrationNoticeToAdmin(); } // Full signon PortalSecurity.SignOn(this.EmailField.Text, this.PasswordField.Text, false, this.RedirectPage); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> private void Page_Load(object sender, EventArgs e) { string _user = string.Empty; string _password = string.Empty; string _alias = string.Empty; // Get Login User from querystring if (Request.Params["usr"] != null) { _user = Request.Params["usr"]; // Get Login Password from querystring if (Request.Params["pwd"] != null) { _password = Request.Params["pwd"]; } // Get portalaias if (Request.Params["alias"] != null) { _alias = HttpUrlBuilder.BuildUrl("~/Default.aspx", 0, string.Empty, Request.Params["alias"]); } //try to validate logon if (PortalSecurity.SignOn(_user, _password, false, _alias) == null) { // Login failed PortalSecurity.AccessDenied(); } } else { //if user has logged on if (Request.IsAuthenticated) { // Redirect user back to the Portal Home Page PortalSecurity.PortalHome(); } else { //User not provided, display logon signIn.Controls.Add(LoadControl("~/DesktopModules/CoreModules/SignIn/Signin.ascx")); } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SaveChangesBtn_Click(object sender, EventArgs e) { Page.Validate(); if (Page.IsValid) { Guid returnID = SaveUserData(); if (returnID == Guid.Empty) { if (selfEdit) { //All should be ok now //Try logoff user PortalSecurity.SignOut(string.Empty, true); //Logon user again with new settings string actualPassword; if (PasswordField.Text.Length != 0) { actualPassword = PasswordField.Text; } else { actualPassword = originalPassword; } //Full signon PortalSecurity.SignOn(EmailField.Text, actualPassword, false, RedirectPage); } else if (RedirectPage == string.Empty) { // Redirect browser back to home page PortalSecurity.PortalHome(); } else { Response.Redirect(RedirectPage); } } } }
private void LoginBtn_Click(Object sender, System.EventArgs e) { // modified by Jonathan Fong // www.gt.com.au string id = null; if (LDAPCheckBox.Checked && GroupList.SelectedValue != "Default") { string dn = "cn=" + email.Text + "," + GroupList.SelectedValue; LDAPHelper.SignOn(dn, password.Text, RememberCheckBox.Checked, null); } else { id = PortalSecurity.SignOn(email.Text, password.Text, RememberCheckBox.Checked); } if (id == null) { Message.Text = "Login failed"; Message.TextKey = "LOGIN_FAILED"; } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { string user = Request.Params["u"]; string pass = Request.Params["p"]; string lnkid = Request.QueryString["lnkid"]; if (!string.IsNullOrEmpty(lnkid)) { int pageId = 0; if (int.TryParse(lnkid, out pageId)) { this.Response.Redirect(Appleseed.Framework.HttpUrlBuilder.BuildUrl(pageId),true); } } if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(pass)) { bool rem = (Request.Params["rem"] ?? "0").ToString().Equals("1") ? true : false; PortalSecurity.SignOn(user, pass, rem, "~/DesktopDefault.aspx"); //PortalSecurity.SignOn(user, pass, false, "~/DesktopDefault.aspx"); } Server.Transfer("DesktopDefault.aspx", true); }
/// <summary> /// Handles the Load event of the DesktopDefault control. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="System.EventArgs"/> instance containing the event data. /// </param> private void DesktopDefault_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.Params["panelist"])) { this.RenderContentAreaList(); } // intento obtener el id de la pagina desde el query string query = Request.Url.Query; int pageId = 0; if (query.Contains("?") && query.ToLower().Contains("pageid")) { int index = query.IndexOf('?'); int indexPageId = query.ToLower().IndexOf("pageid") + 5; if (index < indexPageId - 5) { query = query.Substring(indexPageId + 2, query.Length - indexPageId - 2); index = query.IndexOf('&'); if (index > 0) // no va hasta el final el numero de pagina { query = query.Substring(0, index); } try { pageId = int.Parse(query); } catch (Exception) { pageId = 0; } } else { pageId = 0; } } else { pageId = this.PortalSettings.ActivePage.PageID; } if (pageId == 0) { pageId = Convert.ToInt32(SiteMap.RootNode.ChildNodes[0].Key); this.Response.Redirect(HttpUrlBuilder.BuildUrl(pageId)); } string urlToRedirect = ""; bool redirect = HttpUrlBuilder.ValidateProperUrl(pageId, ref urlToRedirect); if (!redirect) { this.Response.Redirect(urlToRedirect); } if (!PortalSecurity.IsInRoles(this.PortalSettings.ActivePage.AuthorizedRoles) && !this.User.IsInRole("Admins")) { PortalSecurity.AccessDenied(); } else { if (this.Request.Params["r"] == null || this.Request.Params["r"] != "0") { var user = Membership.GetUser(); } var userName = this.Request.Params["u"]; var pass = this.Request.Params["p"]; if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(pass)) { // PortalSecurity.SignOn(userName, pass, false, "~/DesktopDefault.aspx"); var rem = (this.Request.Params["rem"] ?? "0").Equals("1") ? true : false; PortalSecurity.SignOn(userName, pass, rem, "~/DesktopDefault.aspx"); this.Response.Redirect("~/DesktopDefault.aspx"); } if (string.IsNullOrEmpty(Request.Params["panelist"])) { this.LoadPage(); } } }
public Guid SaveUserData() { if (!EditMode) { Guid result = Guid.Empty; if (Session["CameFromSocialNetwork"] == null) { MembershipCreateStatus status = MembershipCreateStatus.Success; MembershipUser user = Membership.Provider.CreateUser(tfEmail.Text, tfPwd.Text, tfEmail.Text, "question", "answer", true, Guid.NewGuid(), out status); this.lblError.Text = string.Empty; switch (status) { case MembershipCreateStatus.DuplicateEmail: case MembershipCreateStatus.DuplicateUserName: this.lblError.Text = Resources.Appleseed.USER_ALREADY_EXISTS; break; case MembershipCreateStatus.ProviderError: break; case MembershipCreateStatus.Success: UpdateProfile(); result = (Guid)user.ProviderUserKey; //if the user is registering himself (thus, is not yet authenticated) we will sign him on and send him to the home page. if (!Context.User.Identity.IsAuthenticated) { PortalSecurity.SignOn(tfEmail.Text, tfPwd.Text, false, HttpUrlBuilder.BuildUrl()); } break; // for every other error message... default: this.lblError.Text = Resources.Appleseed.USER_SAVING_ERROR; break; } return(result); } else { if ((Session["TwitterUserName"] != null) || (Session["LinkedInUserName"] != null)) { // Register Twitter or LinkedIn string userName = (Session["TwitterUserName"] != null) ? Session["TwitterUserName"].ToString() : Session["LinkedInUserName"].ToString(); string password = GeneratePasswordHash(userName); MembershipCreateStatus status = MembershipCreateStatus.Success; MembershipUser user = Membership.Provider.CreateUser(userName, password, tfEmail.Text, "question", "answer", true, Guid.NewGuid(), out status); this.lblError.Text = string.Empty; switch (status) { case MembershipCreateStatus.DuplicateEmail: case MembershipCreateStatus.DuplicateUserName: this.lblError.Text = Resources.Appleseed.USER_ALREADY_EXISTS; break; case MembershipCreateStatus.ProviderError: break; case MembershipCreateStatus.Success: UpdateProfile(); result = (Guid)user.ProviderUserKey; //if the user is registering himself (thus, is not yet authenticated) we will sign him on and send him to the home page. if (!Context.User.Identity.IsAuthenticated) { Session.Contents.Remove("CameFromSocialNetwork"); PortalSecurity.SignOn(userName, password, false, HttpUrlBuilder.BuildUrl()); } break; // for every other error message... default: this.lblError.Text = Resources.Appleseed.USER_SAVING_ERROR; break; } return(result); } else if (Session["FacebookUserName"] != null || Session["GoogleUserEmail"] != null) { // Register Facebook string userName = tfEmail.Text; string password = GeneratePasswordHash(userName); MembershipCreateStatus status = MembershipCreateStatus.Success; MembershipUser user = Membership.Provider.CreateUser(userName, password, userName, "question", "answer", true, Guid.NewGuid(), out status); this.lblError.Text = string.Empty; switch (status) { case MembershipCreateStatus.DuplicateEmail: case MembershipCreateStatus.DuplicateUserName: this.lblError.Text = Resources.Appleseed.USER_ALREADY_EXISTS; break; case MembershipCreateStatus.ProviderError: break; case MembershipCreateStatus.Success: UpdateProfile(); result = (Guid)user.ProviderUserKey; //if the user is registering himself (thus, is not yet authenticated) we will sign him on and send him to the home page. if (!Context.User.Identity.IsAuthenticated) { // Removing names from social networks of sessions if (Session["CameFromGoogleLogin"] != null) { Session.Contents.Remove("CameFromGoogleLogin"); } if (Session["GoogleUserEmail"] != null) { Session.Contents.Remove("GoogleUserEmail"); } if (Session["GoogleUserName"] != null) { Session.Contents.Remove("GoogleUserName"); } if (Session["FacebookUserName"] != null) { Session.Contents.Remove("FacebookUserName"); } if (Session["FacebookName"] != null) { Session.Contents.Remove("FacebookName"); } PortalSecurity.SignOn(userName, password, false, HttpUrlBuilder.BuildUrl()); } break; // for every other error message... default: this.lblError.Text = Resources.Appleseed.USER_SAVING_ERROR; break; } return(result); } else { return(result); } } } else { string Email = tfEmail.Text; string UserName = Membership.GetUserNameByEmail(Email); if (!UserName.Equals(Email)) { // The user Came from twitter Session["CameFromSocialNetwork"] = true; Session["TwitterUserName"] = UserName; Session["LinkedInUserName"] = UserName; Session["deleteCookies"] = true; } UpdateProfile(); return((Guid)Membership.GetUser(UserName, false).ProviderUserKey); } }
protected void loginControl_Authenticate(object sender, AuthenticateEventArgs e) { e.Authenticated = (!string.IsNullOrEmpty(PortalSecurity.SignOn(loginControl.UserName, loginControl.Password, loginControl.RememberMeSet))); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="T:System.EventArgs"/> instance containing the event data. /// </param> private void Page_Load(object sender, EventArgs e) { var _user = string.Empty; var _password = string.Empty; var _alias = string.Empty; var _pageId = 0; // Get Login User from querystring if (this.Request.Params["usr"] != null) { _user = this.Request.Params["usr"]; // Get Login Password from querystring if (this.Request.Params["pwd"] != null) { _password = this.Request.Params["pwd"]; } // Get portalaias if (this.Request.Params["alias"] != null) { _alias = HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, 0, string.Empty, this.Request.Params["alias"]); } if (this.Request.Params["pageId"] != null) { try { _pageId = int.Parse(this.Request.Params["pageId"]); _alias = HttpUrlBuilder.BuildUrl(_pageId); } catch { PortalSecurity.AccessDenied(); } } // try to validate logon if (PortalSecurity.SignOn(_user, _password, true, _alias) == null) { // Login failed PortalSecurity.AccessDenied(); } } else { // if user has logged on if (this.Request.IsAuthenticated) { // Redirect user back to the Portal Home Page PortalSecurity.PortalHome(); } else { // User not provided, display logon var controlStr = "~/DesktopModules/CoreModules/SignIn/Signin.ascx"; if (this.PortalSettings.CustomSettings.ContainsKey("SITESETTINGS_LOGIN_TYPE")) { controlStr = Convert.ToString(this.PortalSettings.CustomSettings["SITESETTINGS_LOGIN_TYPE"]); } try { this.signIn.Controls.Add(this.LoadControl(controlStr)); } catch (Exception exc) { ErrorHandler.Publish(LogLevel.Error, exc); this.signIn.Controls.Add(this.LoadControl("~/DesktopModules/CoreModules/SignIn/Signin.ascx")); } } } }