public void FailedLogin(string usuario, string contraseña) { IniciaSesion login = new IniciaSesion(_driver); login.IngresarCorreoElectronico(usuario); login.IngresarPassword(contraseña); login.IniciarSesion(); var error = new ErrorLogin(_driver); Assert.Equal("Iniciar sesión en Facebook | Facebook", error.GetMensajeError()); }
public async Task <IActionResult> Login(LoginViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { var httpResponse = await _medByteApiService.Login(model); if (httpResponse.IsSuccessStatusCode) { var content = await httpResponse.Content.ReadAsStringAsync(); ErrorLogin errorLogin = JsonConvert.DeserializeObject <ErrorLogin>(content); if (errorLogin.Error != null) { ModelState.AddModelError(string.Empty, "Kullanıcı adı ya da şifre hatalı!"); return(View(model)); } TokenModel tasks = JsonConvert.DeserializeObject <TokenModel>(content); HttpContext.Session.Clear(); HttpContext.Session.SetString("Token", tasks.Token.ToString()); HttpContext.Session.SetString("RefreshToken", tasks.RefreshToken.ToString()); _logger.LogInformation(1, "User logged in."); JwtSecurityToken token = new JwtSecurityTokenHandler().ReadJwtToken(tasks.Token); var claims = new List <Claim> { new Claim(ClaimTypes.Name, model.Email), new Claim("FullName", model.Email) }; foreach (var item in token.Claims) { claims.Add(new Claim(ClaimTypes.Role, item.Value)); } var claimsIdentity = new ClaimsIdentity( claims, CookieAuthenticationDefaults.AuthenticationScheme); await HttpContext.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), new AuthenticationProperties { IsPersistent = model.RememberMe, ExpiresUtc = DateTime.UtcNow.AddMinutes(600) }); return(RedirectToLocal(returnUrl)); } throw new Exception("Cannot retrieve tasks"); } return(View(model)); }
public static void PasswordCheckResponse(Packet _packet) { bool correct = _packet.ReadBool(); if (correct) { System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => { App.console = new MConsoleApp(); App.console.Show(); })); } else { System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => { ErrorLogin errorLogin = new ErrorLogin(); errorLogin.Show(); })); } }
public async Task <IActionResult> Register(RegisterViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { var httpResponse = await _medByteApiService.Register(model); if (httpResponse.IsSuccessStatusCode) { var content = await httpResponse.Content.ReadAsStringAsync(); ErrorLogin errorLogin = JsonConvert.DeserializeObject <ErrorLogin>(content); if (errorLogin.Error != null) { ModelState.AddModelError(string.Empty, "Kayıt oluşturulurken bir hatayla karşılaşıldı şifrenizi büyük küçük harf sayı ve özel karakter içermek zorundadır!"); return(View(model)); } return(RedirectToAction("Login", "Account")); } } // If we got this far, something failed, redisplay form return(View(model)); }