From 5d206ded1b688664ae266e11ad4f6776a90db571 Mon Sep 17 00:00:00 2001 From: Jeff Leung Date: Mon, 27 Dec 2021 00:48:09 -0800 Subject: [PATCH] Don't leak data when we aren't in Development mode --- .../Controllers/SMSReceiverController.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/TwilioSMSReceiver/Controllers/SMSReceiverController.cs b/TwilioSMSReceiver/Controllers/SMSReceiverController.cs index ffd8b81..26c2b6d 100644 --- a/TwilioSMSReceiver/Controllers/SMSReceiverController.cs +++ b/TwilioSMSReceiver/Controllers/SMSReceiverController.cs @@ -19,17 +19,25 @@ namespace TwilioSMSReceiver.Controllers { private readonly SMSDbCtx _context; private readonly IEnumerable _messageHandlers; - public SMSReceiverController(SMSDbCtx context, IEnumerable messageHandlers) + private readonly IWebHostEnvironment _environment; + + public SMSReceiverController(SMSDbCtx context, IEnumerable messageHandlers, + IWebHostEnvironment environment) { _context = context; _messageHandlers = messageHandlers; + _environment = environment; } // GET: api/SMSReceiver [HttpGet] public async Task>> 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