blob: c986d4078ba434a49781367faca40234d3587934 (
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
|
@page "/Login"
@using MatrixRoomUtils.Core.Authentication
@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}!");
RuntimeCache.LastUsedToken = result.AccessToken;
var userinfo = new UserInfo()
{
LoginResponse = result,
Profile = await (await new RemoteHomeServer(result.HomeServer).Configure()).GetProfile(result.UserId)
};
RuntimeCache.LoginSessions.Add(userinfo.AccessToken, userinfo);
await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
}
}
|