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

[PM-3893] Make PreLogin and Register endpoint use identity endpoints (#2772)

This commit is contained in:
André Bispo 2023-09-25 16:28:58 +01:00 committed by GitHub
parent a4a0d31fc6
commit b25c8b0842
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -49,7 +49,7 @@ namespace Bit.Core.Abstractions
Task RefreshIdentityTokenAsync();
Task<SsoPrevalidateResponse> PreValidateSsoAsync(string identifier);
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);
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.")]

View File

@ -148,7 +148,7 @@ namespace Bit.Core.Services
public Task<PreloginResponse> PostPreloginAsync(PreloginRequest request)
{
return SendAsync<PreloginRequest, PreloginResponse>(HttpMethod.Post, "/accounts/prelogin",
request, false, true);
request, false, true, sendToIdentity: true);
}
public Task<long> GetAccountRevisionDateAsync()
@ -170,7 +170,7 @@ namespace Bit.Core.Services
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)
@ -663,14 +663,15 @@ namespace Bit.Core.Services
public Task<TResponse> SendAsync<TResponse>(HttpMethod method, string path, bool authed) =>
SendAsync<object, TResponse>(method, path, null, authed, true);
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())
{
var baseUrl = sendToIdentity ? IdentityBaseUrl : ApiBaseUrl;
requestMessage.Version = new Version(1, 0);
requestMessage.Method = method;
if (!Uri.IsWellFormedUriString(ApiBaseUrl, UriKind.Absolute))
if (!Uri.IsWellFormedUriString(baseUrl, UriKind.Absolute))
{
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)
{