protected void RegisterUser_CreatingUser(object sender, LoginCancelEventArgs e) { string trimmedUserName = RegisterUser.UserName.Trim(); if (RegisterUser.UserName.Length != trimmedUserName.Length) { // Show the error message InvalidUserNameOrPasswordMessage.Text = "The username cannot contain leading or trailing spaces."; InvalidUserNameOrPasswordMessage.Visible = true; // Cancel the create user workflow e.Cancel = true; } else { // Username is valid, make sure that the password does not contain the username if (RegisterUser.Password.IndexOf(RegisterUser.UserName, StringComparison.OrdinalIgnoreCase) >= 0) { // Show the error message InvalidUserNameOrPasswordMessage.Text = "The username may not appear anywhere in the password."; InvalidUserNameOrPasswordMessage.Visible = true; // Cancel the create user workflow e.Cancel = true; } } }
// this code checks for leading and trailing spaces in username // and makes sure the username does not appear in the password protected void CreateUserWizard1_CreatingUser(object sender, LoginCancelEventArgs e) { // declare variable and assign it to the user name textbox string trimmedUserName = CreateUserWizard1.UserName.Trim(); // Check for empty spaces infront and behind the string if (CreateUserWizard1.UserName.Length != trimmedUserName.Length) { // Show the error message InvalidUserNameOrPasswordMessage.Text = "The username cannot contain leading or trailing spaces."; InvalidUserNameOrPasswordMessage.Visible = true; // Cancel the create user workflow e.Cancel = true; } else { /* // Username is valid, make sure that the password does not contain the username if (CreateUserWizard1.Password.IndexOf(CreateUserWizard1.UserName, StringComparison.OrdinalIgnoreCase) >= 0) { // Show the error message InvalidUserNameOrPasswordMessage.Text = "The username may not appear anywhere in the password."; InvalidUserNameOrPasswordMessage.Visible = true; // Cancel the create user workflow e.Cancel = true; } */ } }
protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e) { Logger.Log(TipoEvento.Login, "Termino Session"); Session.Abandon(); FormsAuthentication.SignOut(); }
protected void L1_LoggingIn(object sender, LoginCancelEventArgs e) { //if (((RadioButton)this.L1.FindControl("RadEnglish")).Checked) // CurrentUser.UseLanguage = Language.English; //else // CurrentUser.UseLanguage = Language.Chinese; CheckBox Cb = (CheckBox)L1.FindControl("Cb1"); TextBox UserName = (TextBox)L1.FindControl("UserName"); if (Cb.Checked) { if (HttpContext.Current.Request.Cookies["shinan_login_info"] == null) { HttpCookie newcookie = new HttpCookie("shinan_login_info"); newcookie["user_name"] = UserName.Text; newcookie.Path = "/"; HttpContext.Current.Response.AppendCookie(newcookie); } else { HttpContext.Current.Response.Cookies["shinan_login_info"]["user_name"] = UserName.Text; HttpContext.Current.Request.Cookies["shinan_login_info"]["user_name"] = UserName.Text; } HttpContext.Current.Response.Cookies["shinan_login_info"].Expires = DateTime.Now.AddDays(30); } }
protected void RegisterUser_CreatingUser(object sender, LoginCancelEventArgs e) { DropDownList UserCodDropDownList = (DropDownList)RegisterUserWizardStep.ContentTemplateContainer.FindControl("UserCod"); string usercod = UserCodDropDownList.SelectedValue; //check cod exists SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString); cnn.Open(); SqlCommand cmd = new SqlCommand("select * from UsersInformation where UserCod='" + usercod + "'", cnn); cmd.Connection = cnn; using (SqlDataReader rdr = cmd.ExecuteReader()) { if (rdr.Read()) { ContentPlaceHolder holder = (ContentPlaceHolder)Master.FindControl("MainContent"); Literal errmess = (Literal)holder.FindControl("ErrorMessage"); errmess.Text = "Exista deja un user inregistrat pentru codul de exploatatie: " + usercod; e.Cancel = true; } rdr.Close(); cnn.Close(); } }
protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e) { var user = Membership.GetUser(); if (user == null) { IsCasUser = true; } //var user = Membership.GetUser(); //if (IsEmulating) //{ // FormsAuthentication.SignOut(); // IsEmulating = false; //} //if (user == null) // cas login, redirect to the cas logout page //{ // FormsAuthentication.SignOut(); // // this was raising a "potentially dangerous" warning // //Response.Redirect("https://cas.ucdavis.edu/cas/logout?service=" + STR_RedirectAddress, true); // //Response.Redirect("~/Default.aspx", true); //} //else //{ // FormsAuthentication.SignOut(); // //Response.Redirect("~/Default.aspx", true); //} }
protected void validateUserEmail(object sender, LoginCancelEventArgs e) { TextBox EmailAddressTB = ((TextBox)PWRecovery.UserNameTemplateContainer.FindControl("EmailAddressTB")); Literal ErrorLiteral = ((Literal)PWRecovery.UserNameTemplateContainer.FindControl("ErrorLiteral")); MembershipUser mu = Membership.GetUser(PWRecovery.UserName); if (mu != null) // The username exists { if (mu.Email.Equals(EmailAddressTB.Text)) // Their email matches { //ProfileCommon newProfile = Profile.GetProfile(PWRecovery.UserName); HttpCookie appCookie = new HttpCookie("usernameCookie"); //appCookie.Value = newProfile.FullName; appCookie.Expires = DateTime.Now.AddMinutes(3); Response.Cookies.Add(appCookie); ErrorLiteral.Text = "An email has been sent to your email account with a new password."; } else { e.Cancel = true; ErrorLiteral.Text = "Your username and password do not match"; } } else { e.Cancel = true; ErrorLiteral.Text = "No such user found."; } }
protected void RegisterUser_CreatingUser(object sender, LoginCancelEventArgs e) { string trimmedUserName = RegisterUser.UserName.Trim(); if (RegisterUser.UserName.Length != trimmedUserName.Length) { // Show the error message InvalidUserNameOrPasswordMessage.Text = "Tên đăng nhập không được có khoảng trống ở đầu và cuối."; InvalidUserNameOrPasswordMessage.Visible = true; // Cancel the create user workflow e.Cancel = true; } else { // Username is valid, make sure that the password does not contain the username if (RegisterUser.Password.IndexOf(RegisterUser.UserName, StringComparison.OrdinalIgnoreCase) >= 0) { // Show the error message InvalidUserNameOrPasswordMessage.Text = "Mật khẩu không được chứa tên đăng nhập."; InvalidUserNameOrPasswordMessage.Visible = true; // Cancel the create user workflow e.Cancel = true; } } }
protected void CreateUserWizard1_CreatingUser(object sender, LoginCancelEventArgs e) { if (Page.IsValid) { } }
protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e) { FormsAuthentication.SignOut(); Roles.DeleteCookie(); Session.Clear(); Response.Redirect("~/Views/Login.aspx"); }
protected void CreateUserWizard1_CreatingUser(object sender, LoginCancelEventArgs e) { SqlConnection sqlConn = new SqlConnection(); SqlDataReader myReader; try { sqlConn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; sqlConn.Open(); SqlCommand sqlCmd = new SqlCommand(); sqlCmd.Connection = sqlConn; TextBox userName1 = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName"); TextBox password1 = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Password"); DropDownList usertypeList1 = (DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("userType"); int employerId = 0; if (usertypeList1.SelectedValue.Equals("1")) { TextBox companyName1 = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("companyName"); TextBox address1 = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("address"); TextBox phone1 = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("phone"); TextBox website1 = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("website"); TextBox email1 = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email"); // sqlCmd.CommandText = "insert into employer(companyName, address, phone, email, website) values ('" + companyName1.Text + "', '" + address1.Text + "','" + phone1.Text + "', '" + email1.Text + "','" + website1.Text + "')"; sqlCmd.CommandText = "insert into employer(companyName, address, phone, email, website) values ('" + companyName1.Text + "', '" + address1.Text + "','" + phone1.Text + "', '" + email1.Text + "','"+website1.Text+"')"; sqlCmd.ExecuteNonQuery(); sqlCmd.CommandText = "Select max(Id) from employer"; // employerId = Convert.ToInt32(sqlCmd.ExecuteScalar()); // employerId = Int32.Parse(sqlCmd.ExecuteScalar()); string result = sqlCmd.ExecuteScalar().ToString(); employerId = Int32.Parse(result); } sqlCmd.CommandText = "insert into dbo.Login(UserName, pwd, userType, employerId ) values ('" + userName1.Text + "', '"+password1.Text+"', "+usertypeList1.SelectedValue+","+employerId+")"; sqlCmd.ExecuteNonQuery(); } catch (Exception ex) { Console.Out.WriteLine("Exception occured:" + ex.Message); } finally { if (sqlConn.State == ConnectionState.Open) sqlConn.Close(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void Login_LoggingIn(object sender, LoginCancelEventArgs e) { string uName = this.Login1.UserName.Trim(); //lookup MembershipUser mu = null; try { mu = Membership.GetUser(uName); } catch { } //catch locked out users and cancel if ((mu != null)) { if (!mu.IsApproved) { ((Literal)this.Login1.FindControl("FailureText")).Text = this._notApprovedText; e.Cancel = true; } if (mu.IsLockedOut) { ((Literal)this.Login1.FindControl("FailureText")).Text = this._lockoutText; e.Cancel = true; } } //determine landing page in page_load - just redirect here bool hasReturnUrl = Request.QueryString["ReturnUrl"] != null; bool isAdmin = Roles.IsUserInRole(uName, "Administrators"); if (hasReturnUrl) { this.Login1.DestinationPageUrl = Request.QueryString["ReturnUrl"]; } else if (isAdmin) { //admin page this.Login1.DestinationPageUrl = Website.Pages.Types.AdministratorsDefault; } else { //default page this.Login1.DestinationPageUrl = Website.Pages.Types.Default; } }
protected void loginStatus_LoggingOut(object sender, LoginCancelEventArgs e) { if(Response.Cookies[Globals.PASSWORD_COOKIE] != null) { Response.Cookies.Set(new HttpCookie(Globals.PASSWORD_COOKIE, "")); } Session.Clear(); Globals.IsLogOut = false; FormsAuthentication.RedirectToLoginPage(); }
protected void LoginForm_LoggingIn(object sender, LoginCancelEventArgs e) { NoBotState state; if (!this.NoBot1.IsValid(out state)) { e.Cancel = true; this.LoginForm.FailureText = @"Rejected, user appears to be a bot!"; return; } }
protected void ChangeUserPassword_ChangingPassword(object sender, LoginCancelEventArgs e) { if (!Membership.ValidateUser(User.Identity.Name, ChangeUserPassword.CurrentPassword)) { ChangeUserPassword.ChangePasswordFailureText = "The Old Password entered is incorrect. Please re-enter the old password and try again."; } else if (ChangeUserPassword.NewPassword != ChangeUserPassword.ConfirmNewPassword) { ChangeUserPassword.ChangePasswordFailureText = "The New Password entered is not-consistent. Please ensure the “New Password” and “Confirm New Password” match, and try again."; } }
protected void CreateUserWizard1_CreatingUser(object sender, LoginCancelEventArgs e) { string errorMessage; Control requiredControl; bool b = CheckValid(out requiredControl, out errorMessage); if (!b) { Literal errorMessageLabel = (Literal)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ErrorMessage"); CreateUserWizard1.UnknownErrorMessage = errorMessage; e.Cancel = true; } }
protected void LoginUser_LoggingIn(object sender, LoginCancelEventArgs e) { MembershipUser user = Membership.GetUser(LoginUser.UserName); if (user != null) { if (user.IsApproved == false) { LoginUser.FailureText = "Your account is disabled. Please contact administrator"; } } UserNotify test = new UserNotify("Have Fun !!"); ShoppingCart.GetShoppingCart(LoginUser.UserName); }
protected void CreateUserWizard1_CreatingUser(object sender, LoginCancelEventArgs e) { Bairro = CreateUserWizard1.FindControl<TextBox>("txtBairro"); Email = CreateUserWizard1.FindControl<TextBox>("UserName"); Nome = CreateUserWizard1.FindControl<TextBox>("Email"); CPF = CreateUserWizard1.FindControl<TextBox>("txtCPF"); Telefone = CreateUserWizard1.FindControl<TextBox>("txtTelefone"); CEP = CreateUserWizard1.FindControl<TextBox>("txtCEP"); Estado = CreateUserWizard1.FindControl<TextBox>("txtEstado"); Cidade = CreateUserWizard1.FindControl<TextBox>("txtCidade"); Senha = CreateUserWizard1.FindControl<TextBox>("Password"); Endereco = CreateUserWizard1.FindControl<TextBox>("txtEndereco"); e.Cancel = true; }
public void RegisterUser_CreatingUser(object sender, LoginCancelEventArgs e) { TextBox txtimgcode = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txtimgcode"); Label lblmsg = (Label)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("lblmsg"); if (txtimgcode.Text == this.Session["CaptchaImageText"].ToString()) { e.Cancel = false; } else { e.Cancel = true; } txtimgcode.Text = ""; }
protected void vgRegistration_CreatingUser(object sender, LoginCancelEventArgs e) { //Find the textbox control UserName. TextBox username = vgRegistration.CreateUserStep.ContentTemplateContainer.FindControl("UserName") as TextBox; //Make sure the role dosnt exsist if (!Roles.RoleExists("Client")) { //Create a new Roll called Client Roles.CreateRole("Client"); } Roles.AddUserToRole(username.Text, "Client"); }
protected void ChangingPassword(Object sender, LoginCancelEventArgs e) { if (ChangePassword1.CurrentPassword.ToString() == ChangePassword1.NewPassword.ToString()) { lblError.Visible = true; lblError.Text = "Old password and new password must be different. Please try again."; e.Cancel = true; } else { //This line prevents the error showing up after a first failed attempt. lblError.Visible = false; lblError.Text = ChangePassword1.CurrentPassword.ToString(); } }
protected void changePassword_ChangingPassword(object sender, LoginCancelEventArgs e) { e.Cancel = true; string newPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(this.changePassword.NewPassword, "SHA1"); Configuration webConfig; AuthenticationSection authenticationSection = this.GetFormsAuthConfig(out webConfig); authenticationSection.Forms.Credentials.PasswordFormat = FormsAuthPasswordFormat.SHA1; authenticationSection.Forms.Credentials.Users[0].Password = newPassword; webConfig.Save(); this.Response.Redirect(this.Request.Url.ToString()); }
protected void PasswordRecovery1_VerifyingUser(object sender, LoginCancelEventArgs e) { // find captcha control WebControlCaptcha.CaptchaControl registerCAPTCHA = (WebControlCaptcha.CaptchaControl)PasswordRecovery1.UserNameTemplateContainer.FindControl("CAPTCHA"); // if captcha is missing or incorrect if (!registerCAPTCHA.UserValidated) { // Show the error message FailureText.Text = "Security Code MISSING or INCORRECT!<div class='clearBoth2'></div>"; FailureText.Visible = true; // Cancel the transaction e.Cancel = true; } }
/// <summary> /// Handles the LoggingIn event of the Login1 control. Adjusts the casing (upper/lower) of /// the username logged in with to the same case the user is registered as. This prevents /// case sensitivity issues through the application. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void Login1_LoggingIn(object sender, LoginCancelEventArgs e) { string username = Login1.UserName.Trim(); if (!string.IsNullOrEmpty(username)) { MembershipUser user = Membership.GetUser(username); if (user != null) { // Only adjust the UserName if the password is correct. This is more secure // so a hacker can't find valid usernames if we adjust the case of mis-cased // usernames with incorrect passwords. if (Membership.ValidateUser(user.UserName, Login1.Password)) { Login1.UserName = user.UserName; } } } }
protected void Unnamed_LoggingOut(object sender, LoginCancelEventArgs e) { Context.GetOwinContext().Authentication.SignOut(); Session["New"] = null; Session["SESSIONID"] = null; Session["AdminFlag"] = null; String sessionID = HttpContext.Current.Session.SessionID; //System.Diagnostics.Debug.WriteLine("Site Master Session ID:" + sessionID); Session.Clear(); HttpContext.Current.Session.Abandon(); String MsessionID = HttpContext.Current.Session.SessionID; //System.Diagnostics.Debug.WriteLine("Site Master Abandon Session ID:" + MsessionID); HttpContext.Current.Session.RemoveAll(); //System.Diagnostics.Debug.WriteLine("Site Master Remove Session ID:" + HttpContext.Current.Session.SessionID); HttpContext.Current.Session.Clear(); //System.Diagnostics.Debug.WriteLine("Site Master Clear Session ID:" + HttpContext.Current.Session.SessionID); HttpContext.Current.Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", "")); //System.Diagnostics.Debug.WriteLine("Site Master Cookie Session ID:" + HttpContext.Current.Session.SessionID); }
protected void validateUserEmail(object sender, LoginCancelEventArgs e) { TextBox EmailAddressTB = ((TextBox)PWRecovery.UserNameTemplateContainer.FindControl("EmailAddressTB")); Literal ErrorLiteral = ((Literal)PWRecovery.UserNameTemplateContainer.FindControl("ErrorLiteral")); MembershipUser mu = Membership.GetUser(PWRecovery.UserName); if (mu == null) // The username does not exists { e.Cancel = true; ErrorLiteral.Text = "No such user found."; } else if (!mu.Email.Equals(EmailAddressTB.Text)) // Their email does not match { e.Cancel = true; ErrorLiteral.Text = "Your username and email address do not match"; } }
void LoginControl_LoggingIn(object sender, LoginCancelEventArgs e) { ErrorValidator.Validate(); if (base.Page.IsValid) { string email = UserName.Text; string username = Membership.GetUserNameByEmail(email); if (!string.IsNullOrEmpty(username)) { if (Membership.ValidateUser(username, Password.Text)) FormsAuthentication.RedirectFromLoginPage(username, RememberMe.Checked); } } else { ValidationHelper.SetFocusToFirstError(Page, "login"); } }
protected void Login1_LoggingIn(object sender, LoginCancelEventArgs e) { if (!Page.IsValid) return; if (Request.Browser.IsMobileDevice) { VDMSProvider.Language = ((DropDownList)Login2.FindControl("Language")).SelectedValue; var text = ((TextBox)Login2.FindControl("txtDealerCode")).Text.Trim(); if (!string.IsNullOrEmpty(text)) VDMSProvider.OrgCode = text; else VDMSProvider.OrgCode = ((DropDownList)Login2.FindControl("ddl")).SelectedValue; } else { VDMSProvider.Language = ((DropDownList)Login1.FindControl("Language")).SelectedValue; var text = ((TextBox)Login1.FindControl("txtDealerCode")).Text.Trim(); if (!string.IsNullOrEmpty(text)) VDMSProvider.OrgCode = text; else VDMSProvider.OrgCode = ((DropDownList)Login1.FindControl("ddl")).SelectedValue; } var cookie = new HttpCookie("DealerCode"); cookie.Value = VDMSProvider.OrgCode; cookie.Expires = DateTime.Now.AddMonths(1); Response.Cookies.Add(cookie); }
protected void Unnamed_LoggingOut(object sender, LoginCancelEventArgs e) { Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie); }
protected void Unnamed_LoggingOut(object sender, LoginCancelEventArgs e) { Context.GetOwinContext().Authentication.SignOut(); }
void CreateUserWizard1_CreatingUser(object sender, LoginCancelEventArgs e) { if (Membership.GetUser(CreateUserWizard1.UserName) != null) { e.Cancel = true; lblError.Visible = true; } }
protected void RegisterUser_CreatingUser(object sender, LoginCancelEventArgs e) { try { nome = txtNome.Text; apelido = txtApelido.Text; nif = txtNif.Text; //Não é obrigatorio telemovel = txtTelemovel.Text; localizacao = Convert.ToInt32(cmboxLocalizacao.SelectedItem.Value.ToString()); rua_numero = txtRua_numero.Text;//Não é obrigatório codigo_postal = txtCodigo_postal.Text; } catch (Exception ex) { Console.Write(ex.ToString()); } }
protected void Unnamed_LoggingOut(object sender, LoginCancelEventArgs e) { Session.Clear(); Response.Redirect("Default.aspx"); }