From c7e7734dfc0d4032fab547bdeab5a634ed13c9a0 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 6 Oct 2017 20:47:30 -0400 Subject: [PATCH] null check user --- src/Api/Controllers/SyncController.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Api/Controllers/SyncController.cs b/src/Api/Controllers/SyncController.cs index 1ce18a6df0..3a5dc2f8f5 100644 --- a/src/Api/Controllers/SyncController.cs +++ b/src/Api/Controllers/SyncController.cs @@ -7,6 +7,7 @@ using Bit.Core.Services; using Bit.Core.Repositories; using Bit.Core; using Bit.Core.Enums; +using Bit.Core.Exceptions; namespace Bit.Api.Controllers { @@ -38,6 +39,11 @@ namespace Bit.Api.Controllers public async Task Get() { var user = await _userService.GetUserByPrincipalAsync(User); + if(user == null) + { + throw new BadRequestException("User not found."); + } + var organizationUserDetails = await _organizationUserRepository.GetManyDetailsByUserAsync(user.Id, OrganizationUserStatusType.Confirmed); var folders = await _folderRepository.GetManyByUserIdAsync(user.Id);