mirror of
https://github.com/bitwarden/server.git
synced 2024-12-25 17:27:45 +01:00
[EC-584] Add TryParse to ClientVersion due to QA builds having an appended git hash (#2395)
* [EC-584] Add TryParse to ClientVersion due to QA builds having an appended git hash
* [EC-584] Add string.Split to only get 'ClientVersion' number when the input value includes the git hash
* Revert "[EC-584] Add string.Split to only get 'ClientVersion' number when the input value includes the git hash"
This reverts commit 9ebad69c6a
.
* [EC-584] Update client version check to 2022.12
* [EC-584] Inverted check on ClientVersion
* [EC-584] Bumped version check to version 2023.01
* [EC-584] Removed the 0 prefix from the client version check
This commit is contained in:
parent
f173988979
commit
fe59186c96
@ -41,25 +41,25 @@ public class OrganizationExportController : Controller
|
||||
IEnumerable<Collection> orgCollections = await _collectionService.GetOrganizationCollections(organizationId);
|
||||
(IEnumerable<CipherOrganizationDetails> orgCiphers, Dictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphersGroupDict) = await _cipherService.GetOrganizationCiphers(userId, organizationId);
|
||||
|
||||
// Backward compatibility with versions before 2022.11.0 that use ListResponseModel
|
||||
if (_currentContext.ClientVersion < new Version("2022.11.0"))
|
||||
if (_currentContext.ClientVersion == null || _currentContext.ClientVersion >= new Version("2023.1.0"))
|
||||
{
|
||||
var organizationExportListResponseModel = new OrganizationExportListResponseModel
|
||||
var organizationExportResponseModel = new OrganizationExportResponseModel
|
||||
{
|
||||
Collections = GetOrganizationCollectionsResponse(orgCollections),
|
||||
Ciphers = GetOrganizationCiphersResponse(orgCiphers, collectionCiphersGroupDict)
|
||||
Collections = orgCollections.Select(c => new CollectionResponseModel(c)),
|
||||
Ciphers = orgCiphers.Select(c => new CipherMiniDetailsResponseModel(c, _globalSettings, collectionCiphersGroupDict, c.OrganizationUseTotp))
|
||||
};
|
||||
|
||||
return Ok(organizationExportListResponseModel);
|
||||
return Ok(organizationExportResponseModel);
|
||||
}
|
||||
|
||||
var organizationExportResponseModel = new OrganizationExportResponseModel
|
||||
// Backward compatibility with versions before 2023.1.0 that use ListResponseModel
|
||||
var organizationExportListResponseModel = new OrganizationExportListResponseModel
|
||||
{
|
||||
Collections = orgCollections.Select(c => new CollectionResponseModel(c)),
|
||||
Ciphers = orgCiphers.Select(c => new CipherMiniDetailsResponseModel(c, _globalSettings, collectionCiphersGroupDict, c.OrganizationUseTotp))
|
||||
Collections = GetOrganizationCollectionsResponse(orgCollections),
|
||||
Ciphers = GetOrganizationCiphersResponse(orgCiphers, collectionCiphersGroupDict)
|
||||
};
|
||||
|
||||
return Ok(organizationExportResponseModel);
|
||||
return Ok(organizationExportListResponseModel);
|
||||
}
|
||||
|
||||
private ListResponseModel<CollectionResponseModel> GetOrganizationCollectionsResponse(IEnumerable<Collection> orgCollections)
|
||||
|
@ -82,9 +82,9 @@ public class CurrentContext : ICurrentContext
|
||||
MaybeBot = httpContext.Request.Headers["X-Cf-Maybe-Bot"] == "1";
|
||||
}
|
||||
|
||||
if (httpContext.Request.Headers.ContainsKey("Bitwarden-Client-Version"))
|
||||
if (httpContext.Request.Headers.ContainsKey("Bitwarden-Client-Version") && Version.TryParse(httpContext.Request.Headers["Bitwarden-Client-Version"], out var cVersion))
|
||||
{
|
||||
ClientVersion = new Version(httpContext.Request.Headers["Bitwarden-Client-Version"]);
|
||||
ClientVersion = cVersion;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user