primeros cambios para manejar los permisos y grupos
This commit is contained in:
@@ -24,19 +24,19 @@ public class LoginController: ControllerBase
|
||||
var cookieOptions = new CookieOptions
|
||||
{
|
||||
HttpOnly = true,
|
||||
Secure = true,
|
||||
//SameSite = SameSiteMode.Strict,
|
||||
Expires = DateTimeOffset.UtcNow.AddHours(1)
|
||||
Secure = true,
|
||||
SameSite = SameSiteMode.None,
|
||||
Path = "/Menu",
|
||||
|
||||
Expires = DateTimeOffset.UtcNow.AddHours(1)
|
||||
};
|
||||
|
||||
Response.Cookies.Append("token", tokenString, cookieOptions);
|
||||
return Ok( new {Email = loginDto.Email, Redirect = "/Menu"});
|
||||
return Ok( new {Email = loginDto.Email, Token = tokenString, Redirect = "/Menu"});
|
||||
}
|
||||
|
||||
[HttpPost("api/login/validar")]
|
||||
public IActionResult Verificar([FromBody] AccessDto request){
|
||||
|
||||
Request.Cookies.TryGetValue("token", out var token);
|
||||
public IActionResult Verificar([FromBody] AccessDto request, [FromHeader(Name = "Auth")] string token){
|
||||
|
||||
if (request.Email == String.Empty || token == null ||request.Redirect == string.Empty)
|
||||
{
|
||||
@@ -44,8 +44,13 @@ public class LoginController: ControllerBase
|
||||
}
|
||||
|
||||
bool esValido = RepositorioUsuarios.Singleton.CheckToken(request.Email, token);
|
||||
return (esValido) ?
|
||||
Ok( new { esValido = true}) : Unauthorized( new {esValido = false});
|
||||
if (esValido) {
|
||||
return Ok(new {esValido = esValido});
|
||||
} else {
|
||||
|
||||
return Unauthorized(new {esValido = "el token no es valido"});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user