Custom Actions - ApiController

public class GetDealerByNameController : ApiController
{
[HttpGet(“{name}”)]
public IActionResult Get([FromRoute] string name)
{
string tsql = “SELECT * FROM Dealer WHERE dealercode = '” + AdjustSql(name) + “'”;
var rs = ExecuteRow(tsql);
return Json(rs); // Get the value from route
}
}the above action does not require a user name and password or JWT token to access the data. How do we authenticate and authorize custom actions?

Try adding:if (ValidApiRequest()) {
//… process API request
} else {
return new JsonBoolResult(new { success = false, error = “user not logged in” }, false);
}

Thank you Michael,

ValidApiRequest returns true always regardless of the security. So it produces the same results.Kind regards

Change to:
if (ValidApiRequest() && Security.IsLoggedIn) {

Thanks Michael, that seems to be fixed the issue.Kind regards