1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-22 11:35:21 +01:00

Changed link on Settings "Change Master Password" and "Two Step Login" to go to the web vault settings. Also refactored a bit to reuse the urls (#1809)

This commit is contained in:
Federico Maccaroni 2022-02-24 10:27:08 -03:00 committed by GitHub
parent 9201da8515
commit c74ed668b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 29 deletions

View File

@ -156,7 +156,7 @@ namespace Bit.App.Pages
#endif #endif
return; return;
} }
var webVault = _environmentService.GetWebVaultUrl(); var webVault = _environmentService.GetWebVaultUrl(true);
if (string.IsNullOrWhiteSpace(webVault)) if (string.IsNullOrWhiteSpace(webVault))
{ {
webVault = "https://bitwarden.com"; webVault = "https://bitwarden.com";

View File

@ -27,13 +27,11 @@ namespace Bit.App.Pages
captchaRequiredText = AppResources.CaptchaRequired, captchaRequiredText = AppResources.CaptchaRequired,
}); });
var url = environmentService.GetWebVaultUrl(); var url = environmentService.GetWebVaultUrl() +
if (url == null) "/captcha-mobile-connector.html?" +
{ "data=" + data +
url = "https://vault.bitwarden.com"; "&parent=" + Uri.EscapeDataString(callbackUri) +
} "&v=1";
url += "/captcha-mobile-connector.html?" + "data=" + data +
"&parent=" + Uri.EscapeDataString(callbackUri) + "&v=1";
WebAuthenticatorResult authResult = null; WebAuthenticatorResult authResult = null;
bool cancelled = false; bool cancelled = false;

View File

@ -190,12 +190,7 @@ namespace Bit.App.Pages
public void WebVault() public void WebVault()
{ {
var url = _environmentService.GetWebVaultUrl(); _platformUtilsService.LaunchUri(_environmentService.GetWebVaultUrl());
if (url == null)
{
url = "https://vault.bitwarden.com";
}
_platformUtilsService.LaunchUri(url);
} }
public async Task ShareAsync() public async Task ShareAsync()
@ -214,7 +209,7 @@ namespace Bit.App.Pages
AppResources.TwoStepLogin, AppResources.Yes, AppResources.Cancel); AppResources.TwoStepLogin, AppResources.Yes, AppResources.Cancel);
if (confirmed) 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); AppResources.ChangeMasterPassword, AppResources.Yes, AppResources.Cancel);
if (confirmed) if (confirmed)
{ {
_platformUtilsService.LaunchUri("https://bitwarden.com/help/master-password/#change-your-master-password"); _platformUtilsService.LaunchUri($"{_environmentService.GetWebVaultUrl()}/#/settings");
} }
} }

View File

@ -225,12 +225,7 @@ namespace Bit.App.Utilities
private static string GetSendUrl(SendView send) private static string GetSendUrl(SendView send)
{ {
var environmentService = ServiceContainer.Resolve<IEnvironmentService>("environmentService"); var environmentService = ServiceContainer.Resolve<IEnvironmentService>("environmentService");
var webVaultUrl = environmentService.GetWebVaultUrl(); return environmentService.GetWebSendUrl() + send.AccessId + "/" + send.UrlB64Key;
if (webVaultUrl != null)
{
return webVaultUrl + "/#/send/" + send.AccessId + "/" + send.UrlB64Key;
}
return "https://send.bitwarden.com/#" + send.AccessId + "/" + send.UrlB64Key;
} }
public static async Task<bool> RemoveSendPasswordAsync(string sendId) public static async Task<bool> RemoveSendPasswordAsync(string sendId)

View File

@ -13,7 +13,8 @@ namespace Bit.Core.Abstractions
string WebVaultUrl { get; set; } string WebVaultUrl { get; set; }
string EventsUrl { get; set; } string EventsUrl { get; set; }
string GetWebVaultUrl(); string GetWebVaultUrl(bool returnNullIfDefault = false);
string GetWebSendUrl();
Task<EnvironmentUrlData> SetUrlsAsync(EnvironmentUrlData urls); Task<EnvironmentUrlData> SetUrlsAsync(EnvironmentUrlData urls);
Task SetUrlsFromStorageAsync(); Task SetUrlsFromStorageAsync();
} }

View File

@ -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.Data;
using Bit.Core.Models.Domain; using Bit.Core.Models.Domain;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Bit.Core.Services namespace Bit.Core.Services
{ {
public class EnvironmentService : IEnvironmentService 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 IApiService _apiService;
private readonly IStateService _stateService; private readonly IStateService _stateService;
@ -27,17 +30,24 @@ namespace Bit.Core.Services
public string NotificationsUrl { get; set; } public string NotificationsUrl { get; set; }
public string EventsUrl { get; set; } public string EventsUrl { get; set; }
public string GetWebVaultUrl() public string GetWebVaultUrl(bool returnNullIfDefault = false)
{ {
if (!string.IsNullOrWhiteSpace(WebVaultUrl)) if (!string.IsNullOrWhiteSpace(WebVaultUrl))
{ {
return WebVaultUrl; return WebVaultUrl;
} }
else if (!string.IsNullOrWhiteSpace(BaseUrl))
if (!string.IsNullOrWhiteSpace(BaseUrl))
{ {
return 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() public async Task SetUrlsFromStorageAsync()