diff --git a/src/App/Repositories/AccountsApiRepository.cs b/src/App/Repositories/AccountsApiRepository.cs index 9b55f162a..4d7a0bbd8 100644 --- a/src/App/Repositories/AccountsApiRepository.cs +++ b/src/App/Repositories/AccountsApiRepository.cs @@ -18,7 +18,7 @@ namespace Bit.App.Repositories : base(connectivity, httpService, tokenService) { } - protected override string ApiRoute => "accounts"; + protected override string ApiRoute => "/accounts"; public virtual async Task PostRegisterAsync(RegisterRequest requestObj) { @@ -32,7 +32,7 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage(requestObj) { Method = HttpMethod.Post, - RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/register")), + RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/register")), }; try @@ -64,7 +64,7 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage(requestObj) { Method = HttpMethod.Post, - RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/password-hint")), + RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/password-hint")), }; try @@ -102,7 +102,7 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage() { Method = HttpMethod.Get, - RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/revision-date")), + RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/revision-date")), }; try @@ -151,7 +151,7 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage() { Method = HttpMethod.Get, - RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/profile")), + RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/profile")), }; try @@ -191,7 +191,7 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage() { Method = HttpMethod.Get, - RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/keys")), + RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/keys")), }; try diff --git a/src/App/Repositories/ApiRepository.cs b/src/App/Repositories/ApiRepository.cs index 70d1663d4..271c29c20 100644 --- a/src/App/Repositories/ApiRepository.cs +++ b/src/App/Repositories/ApiRepository.cs @@ -6,7 +6,6 @@ using Bit.App.Abstractions; using Bit.App.Models.Api; using Newtonsoft.Json; using Plugin.Connectivity.Abstractions; -using System.Net; namespace Bit.App.Repositories { @@ -40,7 +39,7 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage() { Method = HttpMethod.Get, - RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/", id)), + RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/", id)), }; try @@ -80,7 +79,7 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage() { Method = HttpMethod.Get, - RequestUri = new Uri(client.BaseAddress, ApiRoute), + RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute)), }; try @@ -120,7 +119,7 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage(requestObj) { Method = HttpMethod.Post, - RequestUri = new Uri(client.BaseAddress, ApiRoute), + RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute)), }; try @@ -160,7 +159,7 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage(requestObj) { Method = HttpMethod.Put, - RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/", id)), + RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/", id)), }; try @@ -200,7 +199,7 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage() { Method = HttpMethod.Delete, - RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/", id)), + RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/", id)), }; try diff --git a/src/App/Repositories/BaseApiRepository.cs b/src/App/Repositories/BaseApiRepository.cs index 7b5a13900..4a26fc665 100644 --- a/src/App/Repositories/BaseApiRepository.cs +++ b/src/App/Repositories/BaseApiRepository.cs @@ -54,7 +54,7 @@ namespace Bit.App.Repositories var requestMessage = new HttpRequestMessage { Method = HttpMethod.Post, - RequestUri = new Uri(client.BaseAddress, "connect/token"), + RequestUri = new Uri(string.Concat(client.BaseAddress, "/connect/token")), Content = new FormUrlEncodedContent(new Dictionary { { "grant_type", "refresh_token" }, @@ -126,7 +126,7 @@ namespace Bit.App.Repositories { } return ApiResult.Failed(response.StatusCode, - new ApiError { Message = "An unknown error has occured." }); + new ApiError { Message = "An unknown error has occurred." }); } protected async Task HandleErrorAsync(HttpResponseMessage response) @@ -140,7 +140,7 @@ namespace Bit.App.Repositories { } return ApiResult.Failed(response.StatusCode, - new ApiError { Message = "An unknown error has occured." }); + new ApiError { Message = "An unknown error has occurred." }); } private async Task> ParseErrorsAsync(HttpResponseMessage response) @@ -186,7 +186,7 @@ namespace Bit.App.Repositories if(errors.Count == 0) { - errors.Add(new ApiError { Message = "An unknown error has occured." }); + errors.Add(new ApiError { Message = "An unknown error has occurred." }); } return errors; diff --git a/src/App/Repositories/CipherApiRepository.cs b/src/App/Repositories/CipherApiRepository.cs index d182d2c88..a10546d6b 100644 --- a/src/App/Repositories/CipherApiRepository.cs +++ b/src/App/Repositories/CipherApiRepository.cs @@ -19,7 +19,7 @@ namespace Bit.App.Repositories : base(connectivity, httpService, tokenService) { } - protected override string ApiRoute => "ciphers"; + protected override string ApiRoute => "/ciphers"; public virtual async Task> GetByIdAsync(string id) { @@ -39,7 +39,7 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage() { Method = HttpMethod.Get, - RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/", id)), + RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/", id)), }; try @@ -79,8 +79,8 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage() { Method = HttpMethod.Get, - RequestUri = new Uri(client.BaseAddress, - string.Format("{0}?includeFolders=false&includeShared=true", ApiRoute)), + RequestUri = new Uri(string.Format("{0}{1}?includeFolders=false&includeShared=true", + client.BaseAddress, ApiRoute)), }; try @@ -124,7 +124,7 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage { Method = HttpMethod.Post, - RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/", cipherId, "/attachment")), + RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/", cipherId, "/attachment")), Content = content }; @@ -165,8 +165,8 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage() { Method = HttpMethod.Delete, - RequestUri = new Uri(client.BaseAddress, - string.Concat(ApiRoute, "/", cipherId, "/attachment/", attachmentId)), + RequestUri = new Uri( + string.Concat(client.BaseAddress, ApiRoute, "/", cipherId, "/attachment/", attachmentId)), }; try diff --git a/src/App/Repositories/ConnectApiRepository.cs b/src/App/Repositories/ConnectApiRepository.cs index 0a17f6008..4b1e5c9d0 100644 --- a/src/App/Repositories/ConnectApiRepository.cs +++ b/src/App/Repositories/ConnectApiRepository.cs @@ -20,7 +20,7 @@ namespace Bit.App.Repositories : base(connectivity, httpService, tokenService) { } - protected override string ApiRoute => "connect"; + protected override string ApiRoute => "/connect"; public virtual async Task> PostTokenAsync(TokenRequest requestObj) { @@ -34,7 +34,7 @@ namespace Bit.App.Repositories var requestMessage = new HttpRequestMessage { Method = HttpMethod.Post, - RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/token")), + RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/token")), Content = new FormUrlEncodedContent(requestObj.ToIdentityTokenRequest()) }; diff --git a/src/App/Repositories/DeviceApiRepository.cs b/src/App/Repositories/DeviceApiRepository.cs index bfe268948..06c86024c 100644 --- a/src/App/Repositories/DeviceApiRepository.cs +++ b/src/App/Repositories/DeviceApiRepository.cs @@ -18,7 +18,7 @@ namespace Bit.App.Repositories : base(connectivity, httpService, tokenService) { } - protected override string ApiRoute => "devices"; + protected override string ApiRoute => "/devices"; public virtual async Task PutTokenAsync(string identifier, DeviceTokenRequest request) { @@ -38,7 +38,7 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage(request) { Method = HttpMethod.Put, - RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/identifier/", identifier, "/token")), + RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/identifier/", identifier, "/token")), }; try @@ -70,8 +70,8 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage { Method = HttpMethod.Put, - RequestUri = new Uri(client.BaseAddress, - string.Concat(ApiRoute, "/identifier/", identifier, "/clear-token")) + RequestUri = new Uri( + string.Concat(client.BaseAddress, ApiRoute, "/identifier/", identifier, "/clear-token")) }; try diff --git a/src/App/Repositories/FolderApiRepository.cs b/src/App/Repositories/FolderApiRepository.cs index c53a80920..5519af938 100644 --- a/src/App/Repositories/FolderApiRepository.cs +++ b/src/App/Repositories/FolderApiRepository.cs @@ -14,6 +14,6 @@ namespace Bit.App.Repositories : base(connectivity, httpService, tokenService) { } - protected override string ApiRoute => "folders"; + protected override string ApiRoute => "/folders"; } } diff --git a/src/App/Repositories/LoginApiRepository.cs b/src/App/Repositories/LoginApiRepository.cs index bc82f4a58..0c8fcb6a6 100644 --- a/src/App/Repositories/LoginApiRepository.cs +++ b/src/App/Repositories/LoginApiRepository.cs @@ -14,6 +14,6 @@ namespace Bit.App.Repositories : base(connectivity, httpService, tokenService) { } - protected override string ApiRoute => "sites"; + protected override string ApiRoute => "/logins"; } } diff --git a/src/App/Repositories/SettingsApiRepository.cs b/src/App/Repositories/SettingsApiRepository.cs index e4c634d36..502871498 100644 --- a/src/App/Repositories/SettingsApiRepository.cs +++ b/src/App/Repositories/SettingsApiRepository.cs @@ -17,7 +17,7 @@ namespace Bit.App.Repositories : base(connectivity, httpService, tokenService) { } - protected override string ApiRoute => "settings"; + protected override string ApiRoute => "/settings"; public virtual async Task> GetDomains(bool excluded = false) { @@ -37,8 +37,8 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage() { Method = HttpMethod.Get, - RequestUri = new Uri(client.BaseAddress, - string.Concat(ApiRoute, "/domains?excluded=", excluded.ToString().ToLowerInvariant())), + RequestUri = new Uri( + string.Concat(client.BaseAddress, ApiRoute, "/domains?excluded=", excluded.ToString().ToLowerInvariant())), }; try diff --git a/src/App/Repositories/TwoFactorApiRepository.cs b/src/App/Repositories/TwoFactorApiRepository.cs index 8540d0f64..50c9695dc 100644 --- a/src/App/Repositories/TwoFactorApiRepository.cs +++ b/src/App/Repositories/TwoFactorApiRepository.cs @@ -16,7 +16,7 @@ namespace Bit.App.Repositories : base(connectivity, httpService, tokenService) { } - protected override string ApiRoute => "two-factor"; + protected override string ApiRoute => "/two-factor"; public virtual async Task PostSendEmailLoginAsync(TwoFactorEmailRequest requestObj) { @@ -30,7 +30,7 @@ namespace Bit.App.Repositories var requestMessage = new TokenHttpRequestMessage(requestObj) { Method = HttpMethod.Post, - RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/send-email-login")), + RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/send-email-login")), }; try