public void ComprobarUsuarioTest() { bool paso = false; paso = UsuariosBLL.ComprobarUsuario("Admin", "SolucionesFB020202003"); Assert.AreEqual(paso, true); }
public async Task <IActionResult> OnGetAsync(string paramUsuario, string paramCOntraseña) { string returnUrl = Url.Content("~/"); try { // Clear the existing external cookie await HttpContext .SignOutAsync( CookieAuthenticationDefaults.AuthenticationScheme); } catch { } if (UsuariosBLL.ComprobarUsuario(paramUsuario, paramCOntraseña)) { // *** !!! This is where you would validate the user !!! *** // In this example we just log the user in // (Always log the user in for this demo) var claims = new List <Claim> { new Claim(ClaimTypes.Name, paramUsuario), new Claim(ClaimTypes.Role, UsuariosBLL.GetNivelAcceso(paramUsuario)), }; var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var authProperties = new AuthenticationProperties { IsPersistent = true, RedirectUri = this.Request.Host.Value }; try { await HttpContext.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties); } catch (Exception ex) { string error = ex.Message; } } return(LocalRedirect(returnUrl)); }