about summary refs log tree commit diff
path: root/ModerationClient/ViewModels/LoginViewModel.cs
blob: 32f0d6e99be95d5981d00b550c7fd0fd7368b5dc (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
using System;
using System.Threading.Tasks;
using ModerationClient.Services;

namespace ModerationClient.ViewModels;

public partial class LoginViewModel(MatrixAuthenticationService authService) : ViewModelBase
{
    private Exception? _exception;
    public string Username { get; set; }
    public string Password { get; set; }

    public Exception? Exception {
        get => _exception;
        private set => SetProperty(ref _exception, value);
    }

    public async Task LoginAsync() {
        try {
            Exception = null;
            await authService.LoginAsync(Username, Password);
        } catch (Exception e) {
            Exception = e;
        }
    }
}