mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-30 17:38:11 +01:00
handle non-root URLs
This commit is contained in:
parent
0eb68ec461
commit
12e3214f70
@ -18,7 +18,7 @@ namespace Bit.App.Repositories
|
|||||||
: base(connectivity, httpService, tokenService)
|
: base(connectivity, httpService, tokenService)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
protected override string ApiRoute => "accounts";
|
protected override string ApiRoute => "/accounts";
|
||||||
|
|
||||||
public virtual async Task<ApiResult> PostRegisterAsync(RegisterRequest requestObj)
|
public virtual async Task<ApiResult> PostRegisterAsync(RegisterRequest requestObj)
|
||||||
{
|
{
|
||||||
@ -32,7 +32,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage(requestObj)
|
var requestMessage = new TokenHttpRequestMessage(requestObj)
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Post,
|
Method = HttpMethod.Post,
|
||||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/register")),
|
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/register")),
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -64,7 +64,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage(requestObj)
|
var requestMessage = new TokenHttpRequestMessage(requestObj)
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Post,
|
Method = HttpMethod.Post,
|
||||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/password-hint")),
|
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/password-hint")),
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -102,7 +102,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage()
|
var requestMessage = new TokenHttpRequestMessage()
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Get,
|
Method = HttpMethod.Get,
|
||||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/revision-date")),
|
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/revision-date")),
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -151,7 +151,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage()
|
var requestMessage = new TokenHttpRequestMessage()
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Get,
|
Method = HttpMethod.Get,
|
||||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/profile")),
|
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/profile")),
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -191,7 +191,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage()
|
var requestMessage = new TokenHttpRequestMessage()
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Get,
|
Method = HttpMethod.Get,
|
||||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/keys")),
|
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/keys")),
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -6,7 +6,6 @@ using Bit.App.Abstractions;
|
|||||||
using Bit.App.Models.Api;
|
using Bit.App.Models.Api;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Plugin.Connectivity.Abstractions;
|
using Plugin.Connectivity.Abstractions;
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
namespace Bit.App.Repositories
|
namespace Bit.App.Repositories
|
||||||
{
|
{
|
||||||
@ -40,7 +39,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage()
|
var requestMessage = new TokenHttpRequestMessage()
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Get,
|
Method = HttpMethod.Get,
|
||||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/", id)),
|
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/", id)),
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -80,7 +79,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage()
|
var requestMessage = new TokenHttpRequestMessage()
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Get,
|
Method = HttpMethod.Get,
|
||||||
RequestUri = new Uri(client.BaseAddress, ApiRoute),
|
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute)),
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -120,7 +119,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage(requestObj)
|
var requestMessage = new TokenHttpRequestMessage(requestObj)
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Post,
|
Method = HttpMethod.Post,
|
||||||
RequestUri = new Uri(client.BaseAddress, ApiRoute),
|
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute)),
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -160,7 +159,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage(requestObj)
|
var requestMessage = new TokenHttpRequestMessage(requestObj)
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Put,
|
Method = HttpMethod.Put,
|
||||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/", id)),
|
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/", id)),
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -200,7 +199,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage()
|
var requestMessage = new TokenHttpRequestMessage()
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Delete,
|
Method = HttpMethod.Delete,
|
||||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/", id)),
|
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/", id)),
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -54,7 +54,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new HttpRequestMessage
|
var requestMessage = new HttpRequestMessage
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Post,
|
Method = HttpMethod.Post,
|
||||||
RequestUri = new Uri(client.BaseAddress, "connect/token"),
|
RequestUri = new Uri(string.Concat(client.BaseAddress, "/connect/token")),
|
||||||
Content = new FormUrlEncodedContent(new Dictionary<string, string>
|
Content = new FormUrlEncodedContent(new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ "grant_type", "refresh_token" },
|
{ "grant_type", "refresh_token" },
|
||||||
@ -126,7 +126,7 @@ namespace Bit.App.Repositories
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
return ApiResult<T>.Failed(response.StatusCode,
|
return ApiResult<T>.Failed(response.StatusCode,
|
||||||
new ApiError { Message = "An unknown error has occured." });
|
new ApiError { Message = "An unknown error has occurred." });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task<ApiResult> HandleErrorAsync(HttpResponseMessage response)
|
protected async Task<ApiResult> HandleErrorAsync(HttpResponseMessage response)
|
||||||
@ -140,7 +140,7 @@ namespace Bit.App.Repositories
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
return ApiResult.Failed(response.StatusCode,
|
return ApiResult.Failed(response.StatusCode,
|
||||||
new ApiError { Message = "An unknown error has occured." });
|
new ApiError { Message = "An unknown error has occurred." });
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<List<ApiError>> ParseErrorsAsync(HttpResponseMessage response)
|
private async Task<List<ApiError>> ParseErrorsAsync(HttpResponseMessage response)
|
||||||
@ -186,7 +186,7 @@ namespace Bit.App.Repositories
|
|||||||
|
|
||||||
if(errors.Count == 0)
|
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;
|
return errors;
|
||||||
|
@ -19,7 +19,7 @@ namespace Bit.App.Repositories
|
|||||||
: base(connectivity, httpService, tokenService)
|
: base(connectivity, httpService, tokenService)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
protected override string ApiRoute => "ciphers";
|
protected override string ApiRoute => "/ciphers";
|
||||||
|
|
||||||
public virtual async Task<ApiResult<CipherResponse>> GetByIdAsync(string id)
|
public virtual async Task<ApiResult<CipherResponse>> GetByIdAsync(string id)
|
||||||
{
|
{
|
||||||
@ -39,7 +39,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage()
|
var requestMessage = new TokenHttpRequestMessage()
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Get,
|
Method = HttpMethod.Get,
|
||||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/", id)),
|
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/", id)),
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -79,8 +79,8 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage()
|
var requestMessage = new TokenHttpRequestMessage()
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Get,
|
Method = HttpMethod.Get,
|
||||||
RequestUri = new Uri(client.BaseAddress,
|
RequestUri = new Uri(string.Format("{0}{1}?includeFolders=false&includeShared=true",
|
||||||
string.Format("{0}?includeFolders=false&includeShared=true", ApiRoute)),
|
client.BaseAddress, ApiRoute)),
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -124,7 +124,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage
|
var requestMessage = new TokenHttpRequestMessage
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Post,
|
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
|
Content = content
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -165,8 +165,8 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage()
|
var requestMessage = new TokenHttpRequestMessage()
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Delete,
|
Method = HttpMethod.Delete,
|
||||||
RequestUri = new Uri(client.BaseAddress,
|
RequestUri = new Uri(
|
||||||
string.Concat(ApiRoute, "/", cipherId, "/attachment/", attachmentId)),
|
string.Concat(client.BaseAddress, ApiRoute, "/", cipherId, "/attachment/", attachmentId)),
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -20,7 +20,7 @@ namespace Bit.App.Repositories
|
|||||||
: base(connectivity, httpService, tokenService)
|
: base(connectivity, httpService, tokenService)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
protected override string ApiRoute => "connect";
|
protected override string ApiRoute => "/connect";
|
||||||
|
|
||||||
public virtual async Task<ApiResult<TokenResponse>> PostTokenAsync(TokenRequest requestObj)
|
public virtual async Task<ApiResult<TokenResponse>> PostTokenAsync(TokenRequest requestObj)
|
||||||
{
|
{
|
||||||
@ -34,7 +34,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new HttpRequestMessage
|
var requestMessage = new HttpRequestMessage
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Post,
|
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())
|
Content = new FormUrlEncodedContent(requestObj.ToIdentityTokenRequest())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ namespace Bit.App.Repositories
|
|||||||
: base(connectivity, httpService, tokenService)
|
: base(connectivity, httpService, tokenService)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
protected override string ApiRoute => "devices";
|
protected override string ApiRoute => "/devices";
|
||||||
|
|
||||||
public virtual async Task<ApiResult> PutTokenAsync(string identifier, DeviceTokenRequest request)
|
public virtual async Task<ApiResult> PutTokenAsync(string identifier, DeviceTokenRequest request)
|
||||||
{
|
{
|
||||||
@ -38,7 +38,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage(request)
|
var requestMessage = new TokenHttpRequestMessage(request)
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Put,
|
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
|
try
|
||||||
@ -70,8 +70,8 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage
|
var requestMessage = new TokenHttpRequestMessage
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Put,
|
Method = HttpMethod.Put,
|
||||||
RequestUri = new Uri(client.BaseAddress,
|
RequestUri = new Uri(
|
||||||
string.Concat(ApiRoute, "/identifier/", identifier, "/clear-token"))
|
string.Concat(client.BaseAddress, ApiRoute, "/identifier/", identifier, "/clear-token"))
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -14,6 +14,6 @@ namespace Bit.App.Repositories
|
|||||||
: base(connectivity, httpService, tokenService)
|
: base(connectivity, httpService, tokenService)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
protected override string ApiRoute => "folders";
|
protected override string ApiRoute => "/folders";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,6 @@ namespace Bit.App.Repositories
|
|||||||
: base(connectivity, httpService, tokenService)
|
: base(connectivity, httpService, tokenService)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
protected override string ApiRoute => "sites";
|
protected override string ApiRoute => "/logins";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ namespace Bit.App.Repositories
|
|||||||
: base(connectivity, httpService, tokenService)
|
: base(connectivity, httpService, tokenService)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
protected override string ApiRoute => "settings";
|
protected override string ApiRoute => "/settings";
|
||||||
|
|
||||||
public virtual async Task<ApiResult<DomainsResponse>> GetDomains(bool excluded = false)
|
public virtual async Task<ApiResult<DomainsResponse>> GetDomains(bool excluded = false)
|
||||||
{
|
{
|
||||||
@ -37,8 +37,8 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage()
|
var requestMessage = new TokenHttpRequestMessage()
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Get,
|
Method = HttpMethod.Get,
|
||||||
RequestUri = new Uri(client.BaseAddress,
|
RequestUri = new Uri(
|
||||||
string.Concat(ApiRoute, "/domains?excluded=", excluded.ToString().ToLowerInvariant())),
|
string.Concat(client.BaseAddress, ApiRoute, "/domains?excluded=", excluded.ToString().ToLowerInvariant())),
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -16,7 +16,7 @@ namespace Bit.App.Repositories
|
|||||||
: base(connectivity, httpService, tokenService)
|
: base(connectivity, httpService, tokenService)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
protected override string ApiRoute => "two-factor";
|
protected override string ApiRoute => "/two-factor";
|
||||||
|
|
||||||
public virtual async Task<ApiResult> PostSendEmailLoginAsync(TwoFactorEmailRequest requestObj)
|
public virtual async Task<ApiResult> PostSendEmailLoginAsync(TwoFactorEmailRequest requestObj)
|
||||||
{
|
{
|
||||||
@ -30,7 +30,7 @@ namespace Bit.App.Repositories
|
|||||||
var requestMessage = new TokenHttpRequestMessage(requestObj)
|
var requestMessage = new TokenHttpRequestMessage(requestObj)
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Post,
|
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
|
try
|
||||||
|
Loading…
Reference in New Issue
Block a user