|
19 | 19 | using System;
|
20 | 20 | using System.Collections.Concurrent;
|
21 | 21 | using System.Collections.Generic;
|
| 22 | +using System.Linq; |
22 | 23 | using System.Net;
|
23 | 24 | using System.Net.Http;
|
24 | 25 | using System.Net.Http.Headers;
|
@@ -139,18 +140,29 @@ public static Task ChangePasswordAsync(User user, string password, string otherU
|
139 | 140 |
|
140 | 141 | public static async Task<UserInfo> RetrieveInfoForUserAsync(User user, string provider, string providerId)
|
141 | 142 | {
|
142 |
| - var uri = new Uri(user.ServerUri, $"/api/providers/{provider}/accounts/{providerId}"); |
| 143 | + var uri = new Uri(user.ServerUri, $"/auth/users/{provider}/{providerId}"); |
143 | 144 | try
|
144 | 145 | {
|
145 | 146 | var response = await MakeAuthRequestAsync(HttpMethod.Get, uri, setupRequest: request =>
|
146 | 147 | request.Headers.TryAddWithoutValidation("Authorization", user.RefreshToken));
|
147 | 148 |
|
| 149 | + var accounts = response["accounts"].Children<JObject>() |
| 150 | + .Select(j => new AccountInfo |
| 151 | + { |
| 152 | + Provider = j["provider"].Value<string>(), |
| 153 | + ProviderUserIdentity = j["provider_id"].Value<string>() |
| 154 | + }) |
| 155 | + .ToArray(); |
| 156 | + |
| 157 | + var metadata = response["metadata"].Children<JObject>() |
| 158 | + .ToDictionary(j => j["key"].Value<string>(), j => j["value"].Value<string>()); |
| 159 | + |
148 | 160 | return new UserInfo
|
149 | 161 | {
|
150 |
| - Identity = response["user"]["id"].Value<string>(), |
151 |
| - IsAdmin = response["user"]["isAdmin"].Value<bool>(), |
152 |
| - Provider = response["provider"].Value<string>(), |
153 |
| - ProviderUserIdentity = response["provider_id"].Value<string>(), |
| 162 | + Identity = response["user_id"].Value<string>(), |
| 163 | + IsAdmin = response["is_admin"].Value<bool>(), |
| 164 | + Accounts = accounts, |
| 165 | + Metadata = metadata |
154 | 166 | };
|
155 | 167 | }
|
156 | 168 | catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound)
|
|
0 commit comments