-
Notifications
You must be signed in to change notification settings - Fork 0
Filters
We have built in 2 filters that we found useful. Please read this if you are new to filters. Filters in ASP.NET Core
- NeedCode
- MustBeLive
If you put this on a controller method, when that method is called the first time the user is redirected to a page and given a code. The user has 5 minutes to enter the provided code and then the original controller method is called again. This provides a barrier between click happy users. For example if you had an admin control panel that allowed you to affect the system and just clicking a button performs the action immediately, it is possible to accidentally initiate this.
[HttpGet("api/test/needcode")]
[NeedCodeFilter]
public IActionResult NeedCodeTest()
{
_logger.LogInformation("api/test/needcode success");
return Ok(new { Message = "Success" });
}
With the attribute MustBeLive performs a check everytime to see if the system is in the "IsLive" mode. For example; the sending of SMS messages to patients can be circumvented when the system is not live.
[HttpGet("api/test/mustbelive")]
[MustBeLiveFilter]
public IActionResult MustBeLiveTest()
{
_logger.LogInformation("api/test/mustbelive success");
return Ok(new { Message = "Success" });
}