blob: 87600c645c281dbaca47bbdb3f2036af24291bf7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
@page "/HSAdmin/HSE/ManageExternalProfiles"
@using ArcaneLibs.Extensions
@using LibMatrix.Responses
<h3>Manage external profiles</h3>
<LinkButton OnClick="AddAllLocalProfiles">Add local sessions</LinkButton>
@foreach(var p in ExternalProfiles)
{
<h4>@p.Key</h4>
<pre>@p.Value.ToJson(indent: true)</pre>
}
@code {
public AuthenticatedHomeserverGeneric? Homeserver { get; set; }
private Dictionary<string, LoginResponse> ExternalProfiles = new();
protected override async Task OnInitializedAsync()
{
Homeserver = await sessionStore.GetCurrentHomeserver(navigateOnFailure: true);
if (Homeserver is null) return;
await LoadProfiles();
await base.OnInitializedAsync();
}
private async Task LoadProfiles() {
if(Homeserver is AuthenticatedHomeserverHSE hse)
{
ExternalProfiles = await hse.GetExternalProfilesAsync();
}
StateHasChanged();
}
private async Task AddAllLocalProfiles() {
if(Homeserver is AuthenticatedHomeserverHSE hse) {
var sessions = await sessionStore.GetAllSessions();
foreach(var session in sessions) {
await hse.SetExternalProfile(session.Value.Auth.UserId, session.Value.Auth);
}
await LoadProfiles();
}
}
}
|