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

This commit is contained in:
Jeff Leung 2021-12-27 00:48:09 -08:00
parent 9cb97b699e
commit 5d206ded1b
1 changed files with 10 additions and 2 deletions

View File

@ -19,17 +19,25 @@ namespace TwilioSMSReceiver.Controllers
{
private readonly SMSDbCtx _context;
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;
_messageHandlers = messageHandlers;
_environment = environment;
}
// GET: api/SMSReceiver
[HttpGet]
public async Task<ActionResult<IEnumerable<SMSModel>>> GetSMSMessages()
{
return await _context.SMSMessages.Include(b => b.MMSContent).ToListAsync();
if (_environment.IsDevelopment())
{
return await _context.SMSMessages.Include(b => b.MMSContent).ToListAsync();
}
return NotFound();
}
// GET: api/SMSReceiver/5