1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-17 16:53:26 +00:00

[PM-3086] Account switcher endpoint use domain string for Bitwarden production environments (#2773)

This commit is contained in:
André Bispo
2023-09-19 10:35:37 +01:00
committed by GitHub
parent 11922c6f49
commit 43bf0fbdb3
2 changed files with 15 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
using Bit.Core.Enums;
using Bit.Core.Models.Data;
using Bit.Core.Models.Domain;
using Bit.Core.Utilities;
@@ -21,14 +22,21 @@ namespace Bit.Core.Models.View
Email = a.Profile?.Email;
Name = a.Profile?.Name;
AvatarColor = a.Profile?.AvatarColor;
if (!string.IsNullOrWhiteSpace(a.Settings?.EnvironmentUrls?.WebVault))
Hostname = ParseEndpoint(a.Settings?.EnvironmentUrls);
}
private string ParseEndpoint(EnvironmentUrlData urls)
{
var url = urls?.WebVault ?? urls?.Base;
if (!string.IsNullOrWhiteSpace(url))
{
Hostname = CoreHelpers.GetHostname(a.Settings?.EnvironmentUrls?.WebVault);
}
else if (!string.IsNullOrWhiteSpace(a.Settings?.EnvironmentUrls?.Base))
{
Hostname = CoreHelpers.GetHostname(a.Settings?.EnvironmentUrls?.Base);
if (url.Contains("bitwarden.com") || url.Contains("bitwarden.eu"))
{
return CoreHelpers.GetDomain(url);
}
return CoreHelpers.GetHostname(url);
}
return string.Empty;
}
public bool IsAccount { get; set; }