From d7040b9ab699ac82cc3724ac592f70ff25f9ffb7 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sun, 7 May 2017 00:08:23 -0400 Subject: [PATCH] add check for org id mismatch --- src/Api/Controllers/LoginsController.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Api/Controllers/LoginsController.cs b/src/Api/Controllers/LoginsController.cs index a7823e3106..a8652ae67a 100644 --- a/src/Api/Controllers/LoginsController.cs +++ b/src/Api/Controllers/LoginsController.cs @@ -117,6 +117,13 @@ namespace Bit.Api.Controllers throw new NotFoundException(); } + var modelOrgId = string.IsNullOrWhiteSpace(model.OrganizationId) ? (Guid?)null : new Guid(model.OrganizationId); + if(login.OrganizationId != modelOrgId) + { + throw new BadRequestException("Organization mismatch. Re-sync if you recently shared this login, " + + "then try again."); + } + await _cipherService.SaveDetailsAsync(model.ToCipherDetails(login), userId); var response = new LoginResponseModel(login);