private static bool ValidateToken(string token, out string username) { username = null; var simplePrinciple = JwtAuthManager.GetPrincipal(token); var identity = simplePrinciple?.Identity as ClaimsIdentity; if (identity == null) { return(false); } if (!identity.IsAuthenticated) { return(false); } var usernameClaim = identity.FindFirst(ClaimTypes.Name); username = usernameClaim?.Value; if (string.IsNullOrEmpty(username)) { return(false); } /*VALIDA SE O UTILIZADOR EXISTE**/ if (!AuthUser.UserExists(username)) { return(false); } return(true); }
public bool ValidateToken(string token) { var simplePrinciple = JwtAuthManager.GetPrincipal(token); Console.WriteLine(simplePrinciple); if (simplePrinciple == null) { return(false); } // You can implement more validation to check whether username exists in your DB or not or something else. return(true); }