Don't leak data when we aren't in Development mode

This commit is contained in:
2021-12-27 00:48:09 -08:00
parent 9cb97b699e
commit 5d206ded1b

View File

@@ -19,18 +19,26 @@ namespace TwilioSMSReceiver.Controllers
{ {
private readonly SMSDbCtx _context; private readonly SMSDbCtx _context;
private readonly IEnumerable<IMessageHandler> _messageHandlers; private readonly IEnumerable<IMessageHandler> _messageHandlers;
public SMSReceiverController(SMSDbCtx context, IEnumerable<IMessageHandler> messageHandlers) private readonly IWebHostEnvironment _environment;
public SMSReceiverController(SMSDbCtx context, IEnumerable<IMessageHandler> messageHandlers,
IWebHostEnvironment environment)
{ {
_context = context; _context = context;
_messageHandlers = messageHandlers; _messageHandlers = messageHandlers;
_environment = environment;
} }
// GET: api/SMSReceiver // GET: api/SMSReceiver
[HttpGet] [HttpGet]
public async Task<ActionResult<IEnumerable<SMSModel>>> GetSMSMessages() public async Task<ActionResult<IEnumerable<SMSModel>>> GetSMSMessages()
{
if (_environment.IsDevelopment())
{ {
return await _context.SMSMessages.Include(b => b.MMSContent).ToListAsync(); return await _context.SMSMessages.Include(b => b.MMSContent).ToListAsync();
} }
return NotFound();
}
// GET: api/SMSReceiver/5 // GET: api/SMSReceiver/5
[HttpGet("{id}")] [HttpGet("{id}")]