about summary refs log tree commit diff
path: root/MatrixUtils.Desktop/LoginWindow.axaml.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-01-24 02:31:56 +0100
committerRory& <root@rory.gay>2024-01-24 17:05:25 +0100
commit03313562d21d5db9bf6a14ebbeab80e06c883d3a (patch)
treee000546a2ee8e6a886a7ed9fd01ad674178fb7cb /MatrixUtils.Desktop/LoginWindow.axaml.cs
parentMake RMU installable (diff)
downloadMatrixUtils-03313562d21d5db9bf6a14ebbeab80e06c883d3a.tar.xz
MRU->RMU, fixes, cleanup
Diffstat (limited to 'MatrixUtils.Desktop/LoginWindow.axaml.cs')
-rw-r--r--MatrixUtils.Desktop/LoginWindow.axaml.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/MatrixUtils.Desktop/LoginWindow.axaml.cs b/MatrixUtils.Desktop/LoginWindow.axaml.cs
new file mode 100644
index 0000000..ac59317
--- /dev/null
+++ b/MatrixUtils.Desktop/LoginWindow.axaml.cs
@@ -0,0 +1,37 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Interactivity;
+using Avalonia.Markup.Xaml;
+using Avalonia.VisualTree;
+
+namespace MatrixUtils.Desktop;
+
+public partial class LoginWindow : Window {
+    private readonly RMUStorageWrapper _storage;
+
+    public LoginWindow(RMUStorageWrapper storage) {
+        _storage = storage;
+        InitializeComponent();
+#if DEBUG
+        this.AttachDevTools();
+#endif
+    }
+
+    private void InitializeComponent() {
+        AvaloniaXamlLoader.Load(this);
+    }
+
+    public string Username { get; set; }
+    public string Password { get; set; }
+    // ReSharper disable once AsyncVoidMethod
+    private async void Login(object? sender, RoutedEventArgs e) {
+        var res = await _storage.Login(Username.Split(':')[1], Username.Split(':')[0][1..], Password);
+        if (res is not null) {
+            await _storage.AddToken(res);
+            Close();
+        }
+        else {
+            Password = "";
+        }
+    }
+}