public void LogInWithWrongPassword() { LogInUserModel user = AccessExcelData.GetTestData <LogInUserModel>("LogInPageData.xlsx", "LogInUserData", "LogInWithWrongPass"); logInPage.FillLogInData(user); logInPage.AssertMessageInvalidPass("Invalid login attempt."); }
public void LogInWithoutPass() { LogInUserModel user = AccessExcelData.GetTestData <LogInUserModel>("LogInPageData.xlsx", "LogInUserData", "LogInWithoutPass"); logInPage.FillLogInData(user); logInPage.AssertMessageWithoutPass("The Password field is required."); }
public ActionResult LoginUser(LogInUserModel login) { if (login.UserName == null || login.Password == null) { ViewBag.Message = "You need to have a valid username and password"; return(View("Error")); } else { var token = GetToken(login.UserName, login.Password); if (string.IsNullOrEmpty(token)) { return(View("Error")); } Session["tokenkey"] = token; using (HttpClient httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Session["tokenkey"].ToString()); var response = httpClient.GetAsync(new Uri(_endpoints.LogInUser)).Result; var message = response.Content.ReadAsStringAsync().Result; if (response.IsSuccessStatusCode) { return(View("Index")); } } return(View("Error")); } }
public void LogInWithWrongEmail() { LogInUserModel user = AccessExcelData.GetTestData <LogInUserModel>("LogInPageData.xlsx", "LogInUserData", "LogInWithWrongEmail"); logInPage.FillLogInData(user); logInPage.AssertMessageInvalidEmail("The Email field is not a valid e-mail address."); }
public void LoginSuccessfully() { LogInUserModel user = AccessExcelData.GetTestData <LogInUserModel>("LogInPageData.xlsx", "LogInUserData", "LogInSuccessfully"); logInPage.FillLogInData(user); logInPage.AssertLogInSuccessfully("Log off"); logInPage.LogOffBtn.Click(); }
public ActionResult LogIn(LogInUserModel model) { return(ValidatedCommandResult(model, new LogInUserCommand(model.Email, model.Password), () => { _authenticationService.SignIn(model.Email); return RedirectToAction("Index"); })); }
public void LogInRemeberMe() { LogInUserModel user = AccessExcelData.GetTestData <LogInUserModel>("LogInPageData.xlsx", "LogInUserData", "LogInWithCheckBox"); logInPage.FillLogInData(user); logInPage.AssertLogInSuccessfully("Log off"); logInPage.Driver.Navigate().GoToUrl("https://google.com"); logInPage.Driver.Navigate().GoToUrl("http://localhost:60634/Article/List"); logInPage.AssertLogInSuccessfully("Log off"); }
public async Task <IActionResult> CreateToken([FromBody] LogInUserModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState.Values)); } var result = await mediator.Send(model); return(Ok(result)); }
public void FillLogInData(LogInUserModel userData) { if (userData.Email != null) { this.LogInEmail.SendKeys(userData.Email); } if (userData.Password != null) { this.LogInPassword.SendKeys(userData.Password); } if (userData.RememberMe == "1") { this.RememberMeCheckBox.Click(); } this.LogInBtn.Click(); }
public async Task <TokenModel> LogIn(LogInUserModel loginUserModel) { var email = await userManager.FindByEmailAsync(loginUserModel.Username); if (email == null) { var user = await userManager.FindByNameAsync(loginUserModel.Username); if (user != null) { var result = await signInManager.CheckPasswordSignInAsync(user, loginUserModel.Password, false); if (result.Succeeded) { //Create token var token = await tokenManager.CreateToken(user); //new manager responsible with creating the token return(new TokenModel { Token = token }); } } } else { var result = await signInManager.CheckPasswordSignInAsync(email, loginUserModel.Password, false); if (result.Succeeded) { //Create token var token = await tokenManager.CreateToken(email); //new manager responsible with creating the token return(new TokenModel { Token = token }); } } return(null); }
public async Task <IActionResult> Login([FromBody] LogInUserModel model) { try { var tokens = await authenticationManager.LogIn(model); if (tokens != null) { return(Ok(tokens)); } else { return(BadRequest("Something failed")); } } catch (Exception ex) { return(BadRequest("Exception caught")); } }
public ActionResult LogIn(LogInUserModel user) { if (ModelState.IsValid) { if (IsValid(user.login, user.password)) { string userData; if (dbUser.getUserByLogin(user.login).admin == true) { userData = "Admin"; } else { userData = "User"; } FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.login, DateTime.Now, DateTime.Now.AddDays(1), false, userData, FormsAuthentication.FormsCookiePath); string encTicket = FormsAuthentication.Encrypt(ticket); Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket)); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Login and password doesn't match"); } } return(View(user)); }