blob: aead5e8fbc6936040f9a6e96eabe1d5aed945d34 (
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
44
45
46
|
@page "/Login"
@using MatrixRoomUtils.Authentication
@using MatrixRoomUtils.Web.Classes
@using Blazored.LocalStorage
@inject ILocalStorageService LocalStorage
<h3>Login</h3>
<label>Homeserver:</label>
<input @bind="homeserver"/>
<br/>
<label>Username:</label>
<input @bind="username"/>
<br/>
<label>Password:</label>
<input @bind="password" type="password"/>
<br/>
<button @onclick="Login">Login</button>
<br/>
<br/>
<LogView></LogView>
@code {
string homeserver = "";
string username = "";
string password = "";
async Task Login()
{
var result = await MatrixAuth.Login(homeserver, username, password);
Console.WriteLine($"Obtained access token for {result.UserId}!");
LocalStorageWrapper.AccessToken = result.AccessToken;
var userinfo = new UserInfo()
{
LoginResponse = result
};
userinfo.Profile = await MatrixAuth.GetProfile(result.HomeServer, result.UserId);
LocalStorageWrapper.LoginSessions.Add(result.AccessToken, userinfo);
LocalStorageWrapper.CurrentHomeserver = await MatrixAuth.ResolveHomeserverFromWellKnown(result.HomeServer);
await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
}
}
|