diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-05-04 00:13:25 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-05-04 00:18:46 +0200 |
commit | b933f7ed1189c7e14d82b4fcf5c98fb3ef4b9cf1 (patch) | |
tree | 4176eb2b7f1befca685d00e119d842eb3f07da1f /MatrixRoomUtils.Web/Pages/UserImportPage.razor | |
parent | Small refactoring (diff) | |
download | MatrixUtils-b933f7ed1189c7e14d82b4fcf5c98fb3ef4b9cf1.tar.xz |
Refactoring
Diffstat (limited to 'MatrixRoomUtils.Web/Pages/UserImportPage.razor')
-rw-r--r-- | MatrixRoomUtils.Web/Pages/UserImportPage.razor | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/MatrixRoomUtils.Web/Pages/UserImportPage.razor b/MatrixRoomUtils.Web/Pages/UserImportPage.razor index 6b5eb77..97a1c44 100644 --- a/MatrixRoomUtils.Web/Pages/UserImportPage.razor +++ b/MatrixRoomUtils.Web/Pages/UserImportPage.razor @@ -1,10 +1,11 @@ @page "/ImportUsers" -@using MatrixRoomUtils.Authentication @using System.Text.Json +@using MatrixRoomUtils.Core +@using MatrixRoomUtils.Core.Authentication @inject ILocalStorageService LocalStorage <h3>Login</h3> -<InputFile OnChange="@FileChanged"></InputFile> +<InputFile OnChange="@FileChanged" accept=".tsv"></InputFile> <br/> <button @onclick="Login">Login</button> <br/><br/> @@ -13,7 +14,7 @@ <table border="1"> @foreach (var (homeserver, username, password) in records) { - <tr style="background-color: @(LocalStorageWrapper.LoginSessions.Any(x => x.Value.LoginResponse.UserId == $"@{username}:{homeserver}") ? "green" : "unset")"> + <tr style="background-color: @(RuntimeCache.LoginSessions.Any(x => x.Value.LoginResponse.UserId == $"@{username}:{homeserver}") ? "green" : "unset")"> <td style="border-width: 1px;">@username</td> <td style="border-width: 1px;">@homeserver</td> <td style="border-width: 1px;">@password.Length chars</td> @@ -31,7 +32,7 @@ { foreach (var (homeserver, username, password) in records) { - if(LocalStorageWrapper.LoginSessions.Any(x => x.Value.LoginResponse.UserId == $"@{username}:{homeserver}")) continue; + if(RuntimeCache.LoginSessions.Any(x => x.Value.LoginResponse.UserId == $"@{username}:{homeserver}")) continue; var result = await MatrixAuth.Login(homeserver, username, password); Console.WriteLine($"Obtained access token for {result.UserId}!"); @@ -40,8 +41,9 @@ LoginResponse = result }; userinfo.Profile = await MatrixAuth.GetProfile(result.HomeServer, result.UserId); + RuntimeCache.LastUsedToken = result.AccessToken; - LocalStorageWrapper.LoginSessions.Add(result.AccessToken, userinfo); + RuntimeCache.LoginSessions.Add(result.AccessToken, userinfo); StateHasChanged(); } |