protected void Login1_LoginError(object sender, EventArgs e) { //There was a problem logging in the user //See if this user exists in the database MembershipUser userInfo = Membership.GetUser(Login2.UserName); if (userInfo == null) { //The user entered an invalid username... ((Label)Login2.FindControl("LoginErrorDetails")).Text = "There is no user in the database with the username " + Login2.UserName; } else { //See if the user is locked out or not approved if (!userInfo.IsApproved) { ((Label)Login2.FindControl("LoginErrorDetails")).Text = "Your account has not yet been approved by the site's administrators. Please try again later..."; } else if (userInfo.IsLockedOut) { ((Label)Login2.FindControl("LoginErrorDetails")).Text = "Your account has been locked out because of a maximum number of incorrect Login attempts. You will NOT be able to Login until you contact a site administrator and have your account unlocked."; } else { //The password was incorrect (don't show anything, the Login control already describes the problem) ((Label)Login2.FindControl("LoginErrorDetails")).Text = String.Empty; } } }
private void Grid_Loaded_1(object sender, RoutedEventArgs e) { Login2.Clear(); Password21.Clear(); Password22.Clear(); Error2.Content = ""; Error2_Copy2.Content = ""; }
private bool SiteSpecificAuthenticationMethod(string UserName, string Password) { SqlConnection Dbconn = new SqlConnection(ConfigurationManager.ConnectionStrings["SSIRentConnectionString"].ToString()); CheckBox cek = (CheckBox)Login2.FindControl("RememberMe"); string cmdtext = "Select FirstName,LastName,USERID,[User] from usysPasswords where [User] = @User and Password = @Password"; SqlCommand cmd = new SqlCommand(cmdtext, Dbconn); Dbconn.Open(); cmd.Parameters.AddWithValue("@User", UserName); cmd.Parameters.AddWithValue("@Password", Password); try { SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { dr.Read(); Session["Name"] = dr["FirstName"].ToString() + " " + dr["LastName"].ToString(); Session["USERID"] = dr["USERID"].ToString(); Session["UserName"] = dr["User"].ToString(); //FormsAuthentication.SetAuthCookie(Login2.UserName,true); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, Login2.UserName, DateTime.Now, DateTime.Now.AddMinutes(120), false, "ApplicationSpecific data for this user.", FormsAuthentication.FormsCookiePath); //encrypt ticket string encTicket = FormsAuthentication.Encrypt(ticket); Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket)); //if (cek.Checked) //{ // HttpCookie cookie = new HttpCookie("username"); // cookie.Value = Login2.UserName; // cookie.Expires = DateTime.Now.AddDays(1);//cookie Expires // HttpContext.Current.Response.AppendCookie(cookie); //} return(true); } else { return(false); } } catch (Exception ex) { return(false); } finally { Dbconn.Close(); Dbconn.Dispose(); cmd.Dispose(); } }
private async void Login_Clicked(object sender, EventArgs e) { var correo = Correo.Text; var password = Password.Text; if (string.IsNullOrEmpty(correo)) { await DisplayAlert("Validación", "Ingrese el Correo", "Aceptar"); Correo.Focus(); return; } if (string.IsNullOrEmpty(password)) { await DisplayAlert("Validación", "Ingrese la Contraseña", "Aceptar"); Password.Focus(); return; } HttpClient publicaciones = new HttpClient(); publicaciones.BaseAddress = new Uri("http://192.168.137.1"); var autenticacion = new Login2 { Correo = correo, Contraseña = password }; string json = JsonConvert.SerializeObject(autenticacion); StringContent content = new StringContent(json, Encoding.UTF8, "application/json"); var request = await publicaciones.PostAsync("Login/api/Login", content); if (request.IsSuccessStatusCode) { var responseJson = await request.Content.ReadAsStringAsync(); var response = JsonConvert.DeserializeObject <bool>(responseJson); if (response == true) { await Navigation.PushAsync(new MasterDetail()); } else { await DisplayAlert("Lo sentimos", "es incorrecto", "Aceptar"); } } else { await DisplayAlert("Error", "Lo sentimos, ocurrio un error con el servidor", "Aceptar"); } }
public void TestMethod1() { Login.GoTo(); Login.ClickLoginLink(); Login.Login("admin", "password"); var employeeList = Login.ClickEmployeeList(); employeeList.ClickCreateNew(); Login2.GoTo(); Login2.ClickLoginLink(); Login2.Login("admin", "password"); var employeeList2 = Login2.ClickEmployeeList(); employeeList2.ClickCreateNew(); }
public object Post(Login2 request) { if (request.Username == SecurityService.Reverse(request.Password)) { var user = new SecurityUser() { Username = request.Username, EmailAddress = request.Username + "@example.local", Timezone = -6 }; return new Login2Response {LoggedInUser = user}; } else if (request.Username.StartsWith("B")) { throw new Exception("No usernames start with B"); } else { return new HttpError("Invalid username and password"); } }
private void Authenticate(AuthenticateEventArgs e) { string company = string.Empty; var ctl = Login2.FindControl("Company"); if (ctl != null) { company = ((TextBox)ctl).Text; } if (_prioritizerService.Authenticate(Login2.UserName, Prioritizer.Shared.Utils.EncodePassword(Login2.Password), company) != null) { e.Authenticated = true; } else { e.Authenticated = false; } }
public void Login_MethodDoesntGetCalledOnce_ShouldReturnFalse() { // Arrange var validationService = Mock.Create <IUserValidation>(); var repo = Mock.Create <ICartRepo>(); Mock.Arrange(() => validationService.ValidateUser(_userName, _password)).Returns(false); Mock.Arrange(() => repo.LoadCart(_userName)).Returns(new List <string> { "1", "2", "3", "4" }); // Act var sut = new Login2(validationService, repo); var result = sut.VerifyUser(_userName, _password); // Assert Mock.Assert(() => validationService.ValidateUser(_userName, _password), Occurs.Once()); Mock.Assert(() => repo.LoadCart(_userName), Occurs.Exactly(0)); }
public void Login_MethodGetsCalledOnce_ShouldReturnTrue() { // Arrange var validationService = Mock.Create <IUserValidation>(); var repo = Mock.Create <ICartRepo>(); Mock.Arrange(() => validationService.ValidateUser(_userName, _password)).Returns(true).Occurs(1); Mock.Arrange(() => repo.LoadCart(_userName)).Returns(new List <string> { "1", "2", "3", "4" }).OccursOnce(); // Act var sut = new Login2(validationService, repo); var result = sut.VerifyUser(_userName, _password); // Assert Mock.Assert(() => validationService.ValidateUser(_userName, _password)); Mock.Assert(() => repo.LoadCart(_userName)); }
public void ShouldMockGenericTypes() { int userID = 5; string userName = "******"; var intList = new List <int> { 1, 2, 3, 4, 5 }; var strList = new List <string> { "1", "2", "3", "4", "5" }; var repo = Mock.Create <ICartRepo>(); repo.Arrange(x => x.GetCartItems <int>(userID)).Returns(intList); repo.Arrange(x => x.GetCartItems <string>(userName)).Returns(strList); var sut = new Login2(null, repo); var intResult = sut.GetCartItems(userID); var strResult = sut.GetCartItems(userName); Assert.AreSame(intList, intResult); Assert.AreSame(strList, strResult); }
public void Login_MethodGetsCalledInOrder_ShouldReturnTrue() { // Arrange var validationService = Mock.Create <IUserValidation>(); var repo = Mock.Create <ICartRepo>(); // The logic in Login2.VerifyUser() needs to execute in the order that the following lines of code are placed // (Reversing the either the logic or these two lines of code will raise an error) Mock.Arrange(() => validationService.ValidateUser(_userName, _password)).Returns(true).InOrder().Occurs(1); Mock.Arrange(() => repo.LoadCart(_userName)).Returns(new List <string> { "1", "2", "3", "4" }).InOrder().OccursOnce(); // Act var sut = new Login2(validationService, repo); var result = sut.VerifyUser(_userName, _password); // Assert Mock.Assert(() => validationService.ValidateUser(_userName, _password)); Mock.Assert(() => repo.LoadCart(_userName)); }
private bool SiteSpecificAuthenticationMethod(string UserName, string Password) { using (SSIRentEntities context = new SSIRentEntities()) { var user = context.Database.SqlQuery <User>("exec sp_SYS_GetUserCredentials @UserName, @Password", new SqlParameter("UserName", UserName), new SqlParameter("Password", Password)).ToList(); if (user.Count > 0) { CheckBox cek = (CheckBox)Login2.FindControl("RememberMe"); Session["Name"] = user[0].Firstname + " " + user[0].LastName; Session["USERID"] = user[0].UserID; Session["UserName"] = UserName; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, Login2.UserName, DateTime.Now, DateTime.Now.AddMinutes(120), false, "ApplicationSpecific data for this user.", FormsAuthentication.FormsCookiePath); //encrypt ticket string encTicket = FormsAuthentication.Encrypt(ticket); Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket)); //if (cek.Checked) //{ // HttpCookie cookie = new HttpCookie("username"); // cookie.Value = Login2.UserName; // // cookie.Expires = DateTime.Now.AddDays(1);//cookie Expires // HttpContext.Current.Response.AppendCookie(cookie); //} return(true); } else { return(false); } } }
private void BtCrear_Click(object sender, RoutedEventArgs e) { Login2 singIn = new Login2(); singIn.ShowDialog(); }
private void Application_Startup(object sender, StartupEventArgs e) { Login2 mw = new Login2(); mw.Show(); }