|
7 | 7 | <MudDialog Class="mud-width-full" ContentClass="uauth-dialog"> |
8 | 8 | <TitleContent> |
9 | 9 | <MudText>Identifier Management</MudText> |
10 | | - <MudText Typo="Typo.subtitle2" Color="Color.Primary">User: @AuthState?.Identity?.DisplayName</MudText> |
| 10 | + <MudText Typo="Typo.subtitle2" Color="Color.Primary"> |
| 11 | + @if (UserKey is null) |
| 12 | + { |
| 13 | + <text>User: @AuthState?.Identity?.DisplayName</text> |
| 14 | + } |
| 15 | + else |
| 16 | + { |
| 17 | + <text>UserKey: @UserKey.Value</text> |
| 18 | + } |
| 19 | + </MudText> |
11 | 20 | </TitleContent> |
12 | 21 | <DialogContent> |
13 | 22 | <MudDataGrid @ref="@_grid" T="UserIdentifierDto" ServerData="LoadServerData" Hover="true" Bordered="true" Striped="true" Dense="true" Elevation="0" |
|
23 | 32 | <PropertyColumn Property="x => x.Id" Title="Id" Editable="false" /> |
24 | 33 | <PropertyColumn Property="x => x.Type" Title="Type" Editable="false" /> |
25 | 34 | <PropertyColumn Property="x => x.Value" Title="Value" /> |
26 | | - <PropertyColumn Property="x => x.IsPrimary" Title="Primary" Editable="false" /> |
27 | | - <PropertyColumn Property="x => x.IsVerified" Title="Verified" Editable="false" /> |
| 35 | + <PropertyColumn Property="x => x.IsPrimary" Title="Primary" Editable="false"> |
| 36 | + <CellTemplate> |
| 37 | + <MudIcon Size="Size.Small" Icon="@(context.Item.IsPrimary? Icons.Material.Filled.Done : Icons.Material.Filled.Close)" /> |
| 38 | + </CellTemplate> |
| 39 | + </PropertyColumn> |
| 40 | + <PropertyColumn Property="x => x.IsVerified" Title="Verified" Editable="false"> |
| 41 | + <CellTemplate> |
| 42 | + <MudIcon Size="Size.Small" Icon="@(context.Item.IsVerified? Icons.Material.Filled.Done : Icons.Material.Filled.Close)" /> |
| 43 | + </CellTemplate> |
| 44 | + </PropertyColumn> |
28 | 45 | <TemplateColumn Title="Actions" Editable="false"> |
29 | 46 | <CellTemplate> |
30 | 47 | <MudStack Style="min-width: 120px" Row="true" Spacing="2" Wrap="Wrap.Wrap"> |
31 | 48 | <MudTooltip Text="Edit" Color="Color.Primary" Delay="300" ShowOnFocus="false"> |
32 | | - <MudIconButton Color="Color.Primary" Variant="Variant.Filled" Icon="@Icons.Material.Filled.Edit" OnClick="@context.Actions.StartEditingItemAsync" /> |
| 49 | + <MudIconButton Color="Color.Primary" Variant="Variant.Filled" Icon="@Icons.Material.Filled.Edit" Size="Size.Small" OnClick="@context.Actions.StartEditingItemAsync" /> |
33 | 50 | </MudTooltip> |
34 | 51 | @if (context.Item.IsPrimary) |
35 | 52 | { |
36 | 53 | <MudTooltip Text="Unset Primary" Color="Color.Primary" Delay="300" ShowOnFocus="false"> |
37 | | - <MudIconButton Color="Color.Primary" Variant="Variant.Filled" Icon="@Icons.Material.Filled.KeyOff" OnClick="@(() => UnsetPrimaryAsync(context.Item.Id))" /> |
| 54 | + <MudIconButton Color="Color.Primary" Variant="Variant.Filled" Icon="@Icons.Material.Filled.KeyOff" Size="Size.Small" OnClick="@(() => UnsetPrimaryAsync(context.Item.Id))" /> |
38 | 55 | </MudTooltip> |
39 | 56 | } |
40 | 57 | else |
41 | 58 | { |
42 | 59 | <MudTooltip Text="Set Primary" Color="Color.Primary" Delay="300" ShowOnFocus="false"> |
43 | | - <MudIconButton Color="Color.Primary" Variant="Variant.Filled" Icon="@Icons.Material.Filled.Key" OnClick="@(() => SetPrimaryAsync(context.Item.Id))" /> |
| 60 | + <MudIconButton Color="Color.Primary" Variant="Variant.Filled" Icon="@Icons.Material.Filled.Key" Size="Size.Small" OnClick="@(() => SetPrimaryAsync(context.Item.Id))" /> |
44 | 61 | </MudTooltip> |
45 | 62 | } |
46 | 63 |
|
47 | 64 | <MudTooltip Text="Verify" Color="Color.Primary" Delay="300" ShowOnFocus="false"> |
48 | | - <MudIconButton Color="Color.Primary" Variant="Variant.Filled" Icon="@Icons.Material.Filled.Verified" OnClick="@(() => VerifyAsync(context.Item.Id))" /> |
| 65 | + <MudIconButton Color="Color.Primary" Variant="Variant.Filled" Icon="@Icons.Material.Filled.Verified" Size="Size.Small" OnClick="@(() => VerifyAsync(context.Item.Id))" /> |
49 | 66 | </MudTooltip> |
50 | 67 |
|
51 | 68 | <MudTooltip Text="Delete" Color="Color.Error" Delay="300" ShowOnFocus="false"> |
52 | | - <MudIconButton Color="Color.Error" Variant="Variant.Filled" Icon="@Icons.Material.Filled.Delete" OnClick="@(() => DeleteIdentifier(context.Item.Id))" /> |
| 69 | + <MudIconButton Color="Color.Error" Variant="Variant.Filled" Icon="@Icons.Material.Filled.Delete" Size="Size.Small" OnClick="@(() => DeleteIdentifier(context.Item.Id))" /> |
53 | 70 | </MudTooltip> |
54 | 71 | </MudStack> |
55 | 72 | </CellTemplate> |
|
85 | 102 |
|
86 | 103 | <DialogActions> |
87 | 104 | <MudButton OnClick="Cancel">Cancel</MudButton> |
88 | | - <MudButton Color="Color.Primary" OnClick="Submit">OK</MudButton> |
89 | 105 | </DialogActions> |
90 | 106 | </MudDialog> |
91 | 107 |
|
|
103 | 119 | [Parameter] |
104 | 120 | public UAuthState AuthState { get; set; } = default!; |
105 | 121 |
|
| 122 | + [Parameter] |
| 123 | + public UserKey? UserKey { get; set; } |
| 124 | + |
106 | 125 | protected override async Task OnAfterRenderAsync(bool firstRender) |
107 | 126 | { |
108 | 127 | await base.OnAfterRenderAsync(firstRender); |
|
130 | 149 | Descending = sort?.Descending ?? false |
131 | 150 | }; |
132 | 151 |
|
133 | | - var res = await UAuthClient.Identifiers.GetMyIdentifiersAsync(req); |
| 152 | + UAuthResult<PagedResult<UserIdentifierDto>> res; |
| 153 | + |
| 154 | + if (UserKey is null) |
| 155 | + { |
| 156 | + res = await UAuthClient.Identifiers.GetMyIdentifiersAsync(req); |
| 157 | + } |
| 158 | + else |
| 159 | + { |
| 160 | + res = await UAuthClient.Identifiers.GetUserIdentifiersAsync(UserKey.Value, req); |
| 161 | + } |
134 | 162 |
|
135 | 163 | if (!res.IsSuccess || res.Value is null) |
136 | 164 | { |
|
190 | 218 | Id = item.Id, |
191 | 219 | NewValue = item.Value |
192 | 220 | }; |
193 | | - var result = await UAuthClient.Identifiers.UpdateSelfAsync(updateRequest); |
| 221 | + |
| 222 | + UAuthResult result; |
| 223 | + |
| 224 | + if (UserKey is null) |
| 225 | + { |
| 226 | + result = await UAuthClient.Identifiers.UpdateSelfAsync(updateRequest); |
| 227 | + } |
| 228 | + else |
| 229 | + { |
| 230 | + result = await UAuthClient.Identifiers.UpdateAdminAsync(UserKey.Value, updateRequest); |
| 231 | + } |
| 232 | + |
194 | 233 | if (result.IsSuccess) |
195 | 234 | { |
196 | 235 | Snackbar.Add("Identifier updated successfully", Severity.Success); |
|
219 | 258 | IsPrimary = _newIdentifierPrimary |
220 | 259 | }; |
221 | 260 |
|
222 | | - var result = await UAuthClient.Identifiers.AddSelfAsync(request); |
| 261 | + UAuthResult result; |
| 262 | + |
| 263 | + if (UserKey is null) |
| 264 | + { |
| 265 | + result = await UAuthClient.Identifiers.AddSelfAsync(request); |
| 266 | + } |
| 267 | + else |
| 268 | + { |
| 269 | + result = await UAuthClient.Identifiers.AddAdminAsync(UserKey.Value, request); |
| 270 | + } |
| 271 | + |
223 | 272 | if (result.IsSuccess) |
224 | 273 | { |
225 | 274 | Snackbar.Add("Identifier added successfully", Severity.Success); |
|
252 | 301 | } |
253 | 302 |
|
254 | 303 | VerifyUserIdentifierRequest request = new() { IdentifierId = id }; |
255 | | - var result = await UAuthClient.Identifiers.VerifySelfAsync(request); |
| 304 | + UAuthResult result; |
| 305 | + |
| 306 | + if (UserKey is null) |
| 307 | + { |
| 308 | + result = await UAuthClient.Identifiers.VerifySelfAsync(request); |
| 309 | + } |
| 310 | + else |
| 311 | + { |
| 312 | + result = await UAuthClient.Identifiers.VerifyAdminAsync(UserKey.Value, request); |
| 313 | + } |
| 314 | + |
256 | 315 | if (result.IsSuccess) |
257 | 316 | { |
258 | 317 | Snackbar.Add("Identifier verified successfully", Severity.Success); |
|
268 | 327 | private async Task SetPrimaryAsync(Guid id) |
269 | 328 | { |
270 | 329 | SetPrimaryUserIdentifierRequest request = new() { IdentifierId = id }; |
271 | | - var result = await UAuthClient.Identifiers.SetPrimarySelfAsync(request); |
| 330 | + UAuthResult result; |
| 331 | + |
| 332 | + if (UserKey is null) |
| 333 | + { |
| 334 | + result = await UAuthClient.Identifiers.SetPrimarySelfAsync(request); |
| 335 | + } |
| 336 | + else |
| 337 | + { |
| 338 | + result = await UAuthClient.Identifiers.SetPrimaryAdminAsync(UserKey.Value, request); |
| 339 | + } |
| 340 | + |
272 | 341 | if (result.IsSuccess) |
273 | 342 | { |
274 | 343 | Snackbar.Add("Primary identifier set successfully", Severity.Success); |
|
284 | 353 | private async Task UnsetPrimaryAsync(Guid id) |
285 | 354 | { |
286 | 355 | UnsetPrimaryUserIdentifierRequest request = new() { IdentifierId = id }; |
287 | | - var result = await UAuthClient.Identifiers.UnsetPrimarySelfAsync(request); |
| 356 | + UAuthResult result; |
| 357 | + |
| 358 | + if (UserKey is null) |
| 359 | + { |
| 360 | + result = await UAuthClient.Identifiers.UnsetPrimarySelfAsync(request); |
| 361 | + } |
| 362 | + else |
| 363 | + { |
| 364 | + result = await UAuthClient.Identifiers.UnsetPrimaryAdminAsync(UserKey.Value, request); |
| 365 | + } |
| 366 | + |
288 | 367 | if (result.IsSuccess) |
289 | 368 | { |
290 | 369 | Snackbar.Add("Primary identifier unset successfully", Severity.Success); |
|
300 | 379 | private async Task DeleteIdentifier(Guid id) |
301 | 380 | { |
302 | 381 | DeleteUserIdentifierRequest request = new() { IdentifierId = id }; |
303 | | - var result = await UAuthClient.Identifiers.DeleteSelfAsync(request); |
| 382 | + UAuthResult result; |
| 383 | + |
| 384 | + if (UserKey is null) |
| 385 | + { |
| 386 | + result = await UAuthClient.Identifiers.DeleteSelfAsync(request); |
| 387 | + } |
| 388 | + else |
| 389 | + { |
| 390 | + result = await UAuthClient.Identifiers.DeleteAdminAsync(UserKey.Value, request); |
| 391 | + } |
| 392 | + |
304 | 393 | if (result.IsSuccess) |
305 | 394 | { |
306 | 395 | Snackbar.Add("Identifier deleted successfully", Severity.Success); |
|
313 | 402 | } |
314 | 403 | } |
315 | 404 |
|
316 | | - private void Submit() => MudDialog.Close(DialogResult.Ok(true)); |
317 | | - |
318 | 405 | private void Cancel() => MudDialog.Cancel(); |
319 | 406 | } |
0 commit comments