mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 10:28:28 +03:00
[PM-3893] Make PreLogin and Register endpoint use identity endpoints (#2772)
This commit is contained in:
parent
a4a0d31fc6
commit
b25c8b0842
2 changed files with 7 additions and 6 deletions
|
@ -49,7 +49,7 @@ namespace Bit.Core.Abstractions
|
||||||
Task RefreshIdentityTokenAsync();
|
Task RefreshIdentityTokenAsync();
|
||||||
Task<SsoPrevalidateResponse> PreValidateSsoAsync(string identifier);
|
Task<SsoPrevalidateResponse> PreValidateSsoAsync(string identifier);
|
||||||
Task<TResponse> SendAsync<TRequest, TResponse>(HttpMethod method, string path,
|
Task<TResponse> SendAsync<TRequest, TResponse>(HttpMethod method, string path,
|
||||||
TRequest body, bool authed, bool hasResponse, Action<HttpRequestMessage> alterRequest, bool logoutOnUnauthorized = true);
|
TRequest body, bool authed, bool hasResponse, Action<HttpRequestMessage> alterRequest, bool logoutOnUnauthorized = true, bool sendToIdentity = false);
|
||||||
Task<HttpResponseMessage> SendAsync(HttpRequestMessage requestMessage, CancellationToken cancellationToken = default);
|
Task<HttpResponseMessage> SendAsync(HttpRequestMessage requestMessage, CancellationToken cancellationToken = default);
|
||||||
void SetUrls(EnvironmentUrls urls);
|
void SetUrls(EnvironmentUrls urls);
|
||||||
[Obsolete("Mar 25 2021: This method has been deprecated in favor of direct uploads. This method still exists for backward compatibility with old server versions.")]
|
[Obsolete("Mar 25 2021: This method has been deprecated in favor of direct uploads. This method still exists for backward compatibility with old server versions.")]
|
||||||
|
|
|
@ -148,7 +148,7 @@ namespace Bit.Core.Services
|
||||||
public Task<PreloginResponse> PostPreloginAsync(PreloginRequest request)
|
public Task<PreloginResponse> PostPreloginAsync(PreloginRequest request)
|
||||||
{
|
{
|
||||||
return SendAsync<PreloginRequest, PreloginResponse>(HttpMethod.Post, "/accounts/prelogin",
|
return SendAsync<PreloginRequest, PreloginResponse>(HttpMethod.Post, "/accounts/prelogin",
|
||||||
request, false, true);
|
request, false, true, sendToIdentity: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<long> GetAccountRevisionDateAsync()
|
public Task<long> GetAccountRevisionDateAsync()
|
||||||
|
@ -170,7 +170,7 @@ namespace Bit.Core.Services
|
||||||
|
|
||||||
public Task PostRegisterAsync(RegisterRequest request)
|
public Task PostRegisterAsync(RegisterRequest request)
|
||||||
{
|
{
|
||||||
return SendAsync<RegisterRequest, object>(HttpMethod.Post, "/accounts/register", request, false, false);
|
return SendAsync<RegisterRequest, object>(HttpMethod.Post, "/accounts/register", request, false, false, sendToIdentity: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task PostAccountKeysAsync(KeysRequest request)
|
public Task PostAccountKeysAsync(KeysRequest request)
|
||||||
|
@ -663,14 +663,15 @@ namespace Bit.Core.Services
|
||||||
public Task<TResponse> SendAsync<TResponse>(HttpMethod method, string path, bool authed) =>
|
public Task<TResponse> SendAsync<TResponse>(HttpMethod method, string path, bool authed) =>
|
||||||
SendAsync<object, TResponse>(method, path, null, authed, true);
|
SendAsync<object, TResponse>(method, path, null, authed, true);
|
||||||
public async Task<TResponse> SendAsync<TRequest, TResponse>(HttpMethod method, string path, TRequest body,
|
public async Task<TResponse> SendAsync<TRequest, TResponse>(HttpMethod method, string path, TRequest body,
|
||||||
bool authed, bool hasResponse, Action<HttpRequestMessage> alterRequest = null, bool logoutOnUnauthorized = true)
|
bool authed, bool hasResponse, Action<HttpRequestMessage> alterRequest = null, bool logoutOnUnauthorized = true, bool sendToIdentity = false)
|
||||||
{
|
{
|
||||||
using (var requestMessage = new HttpRequestMessage())
|
using (var requestMessage = new HttpRequestMessage())
|
||||||
{
|
{
|
||||||
|
var baseUrl = sendToIdentity ? IdentityBaseUrl : ApiBaseUrl;
|
||||||
requestMessage.Version = new Version(1, 0);
|
requestMessage.Version = new Version(1, 0);
|
||||||
requestMessage.Method = method;
|
requestMessage.Method = method;
|
||||||
|
|
||||||
if (!Uri.IsWellFormedUriString(ApiBaseUrl, UriKind.Absolute))
|
if (!Uri.IsWellFormedUriString(baseUrl, UriKind.Absolute))
|
||||||
{
|
{
|
||||||
throw new ApiException(new ErrorResponse
|
throw new ApiException(new ErrorResponse
|
||||||
{
|
{
|
||||||
|
@ -680,7 +681,7 @@ namespace Bit.Core.Services
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
requestMessage.RequestUri = new Uri(string.Concat(ApiBaseUrl, path));
|
requestMessage.RequestUri = new Uri(string.Concat(baseUrl, path));
|
||||||
|
|
||||||
if (body != null)
|
if (body != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue