diff --git a/src/App/Pages/Accounts/LockPageViewModel.cs b/src/App/Pages/Accounts/LockPageViewModel.cs index 6aa5d2b28..05607ccbb 100644 --- a/src/App/Pages/Accounts/LockPageViewModel.cs +++ b/src/App/Pages/Accounts/LockPageViewModel.cs @@ -156,7 +156,7 @@ namespace Bit.App.Pages #endif return; } - var webVault = _environmentService.GetWebVaultUrl(); + var webVault = _environmentService.GetWebVaultUrl(true); if (string.IsNullOrWhiteSpace(webVault)) { webVault = "https://bitwarden.com"; diff --git a/src/App/Pages/CaptchaProtectedViewModel.cs b/src/App/Pages/CaptchaProtectedViewModel.cs index 64693c5eb..d5d019dff 100644 --- a/src/App/Pages/CaptchaProtectedViewModel.cs +++ b/src/App/Pages/CaptchaProtectedViewModel.cs @@ -27,13 +27,11 @@ namespace Bit.App.Pages captchaRequiredText = AppResources.CaptchaRequired, }); - var url = environmentService.GetWebVaultUrl(); - if (url == null) - { - url = "https://vault.bitwarden.com"; - } - url += "/captcha-mobile-connector.html?" + "data=" + data + - "&parent=" + Uri.EscapeDataString(callbackUri) + "&v=1"; + var url = environmentService.GetWebVaultUrl() + + "/captcha-mobile-connector.html?" + + "data=" + data + + "&parent=" + Uri.EscapeDataString(callbackUri) + + "&v=1"; WebAuthenticatorResult authResult = null; bool cancelled = false; diff --git a/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs b/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs index 87afeb2a0..b4f689af9 100644 --- a/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs +++ b/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs @@ -190,12 +190,7 @@ namespace Bit.App.Pages public void WebVault() { - var url = _environmentService.GetWebVaultUrl(); - if (url == null) - { - url = "https://vault.bitwarden.com"; - } - _platformUtilsService.LaunchUri(url); + _platformUtilsService.LaunchUri(_environmentService.GetWebVaultUrl()); } public async Task ShareAsync() @@ -214,7 +209,7 @@ namespace Bit.App.Pages AppResources.TwoStepLogin, AppResources.Yes, AppResources.Cancel); if (confirmed) { - _platformUtilsService.LaunchUri("https://bitwarden.com/help/setup-two-step-login/"); + _platformUtilsService.LaunchUri($"{_environmentService.GetWebVaultUrl()}/#/settings"); } } @@ -224,7 +219,7 @@ namespace Bit.App.Pages AppResources.ChangeMasterPassword, AppResources.Yes, AppResources.Cancel); if (confirmed) { - _platformUtilsService.LaunchUri("https://bitwarden.com/help/master-password/#change-your-master-password"); + _platformUtilsService.LaunchUri($"{_environmentService.GetWebVaultUrl()}/#/settings"); } } diff --git a/src/App/Utilities/AppHelpers.cs b/src/App/Utilities/AppHelpers.cs index 82d8b6ec0..8dc186a30 100644 --- a/src/App/Utilities/AppHelpers.cs +++ b/src/App/Utilities/AppHelpers.cs @@ -225,12 +225,7 @@ namespace Bit.App.Utilities private static string GetSendUrl(SendView send) { var environmentService = ServiceContainer.Resolve("environmentService"); - var webVaultUrl = environmentService.GetWebVaultUrl(); - if (webVaultUrl != null) - { - return webVaultUrl + "/#/send/" + send.AccessId + "/" + send.UrlB64Key; - } - return "https://send.bitwarden.com/#" + send.AccessId + "/" + send.UrlB64Key; + return environmentService.GetWebSendUrl() + send.AccessId + "/" + send.UrlB64Key; } public static async Task RemoveSendPasswordAsync(string sendId) diff --git a/src/Core/Abstractions/IEnvironmentService.cs b/src/Core/Abstractions/IEnvironmentService.cs index 8ce168128..06e76959a 100644 --- a/src/Core/Abstractions/IEnvironmentService.cs +++ b/src/Core/Abstractions/IEnvironmentService.cs @@ -13,7 +13,8 @@ namespace Bit.Core.Abstractions string WebVaultUrl { get; set; } string EventsUrl { get; set; } - string GetWebVaultUrl(); + string GetWebVaultUrl(bool returnNullIfDefault = false); + string GetWebSendUrl(); Task SetUrlsAsync(EnvironmentUrlData urls); Task SetUrlsFromStorageAsync(); } diff --git a/src/Core/Services/EnvironmentService.cs b/src/Core/Services/EnvironmentService.cs index b5a6e4511..e3550d9b8 100644 --- a/src/Core/Services/EnvironmentService.cs +++ b/src/Core/Services/EnvironmentService.cs @@ -1,13 +1,16 @@ -using Bit.Core.Abstractions; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using Bit.Core.Abstractions; using Bit.Core.Models.Data; using Bit.Core.Models.Domain; -using System.Text.RegularExpressions; -using System.Threading.Tasks; namespace Bit.Core.Services { public class EnvironmentService : IEnvironmentService { + private const string DEFAULT_WEB_VAULT_URL = "https://vault.bitwarden.com"; + private const string DEFAULT_WEB_SEND_URL = "https://send.bitwarden.com/#"; + private readonly IApiService _apiService; private readonly IStateService _stateService; @@ -27,17 +30,24 @@ namespace Bit.Core.Services public string NotificationsUrl { get; set; } public string EventsUrl { get; set; } - public string GetWebVaultUrl() + public string GetWebVaultUrl(bool returnNullIfDefault = false) { if (!string.IsNullOrWhiteSpace(WebVaultUrl)) { return WebVaultUrl; } - else if (!string.IsNullOrWhiteSpace(BaseUrl)) + + if (!string.IsNullOrWhiteSpace(BaseUrl)) { return BaseUrl; } - return null; + + return returnNullIfDefault ? (string)null : DEFAULT_WEB_VAULT_URL; + } + + public string GetWebSendUrl() + { + return GetWebVaultUrl(true) is string webVaultUrl ? $"{webVaultUrl}/#/send/" : DEFAULT_WEB_SEND_URL; } public async Task SetUrlsFromStorageAsync()