fully implemented login
This commit is contained in:
parent
f6e3687ec2
commit
55b0ff1c45
10 changed files with 112 additions and 12 deletions
|
@ -8,7 +8,7 @@ namespace WeeXnes.Core
|
|||
{
|
||||
public class Information
|
||||
{
|
||||
public const string Version = "4.4.7";
|
||||
public const string Version = "4.4.8";
|
||||
public const string EncryptionHash = "8zf5#RdyQ]$4x4_";
|
||||
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace WeeXnes.Core
|
|||
}
|
||||
public static void arg_debugMode()
|
||||
{
|
||||
|
||||
MessageBox.Show("user debug mode enabled");
|
||||
}
|
||||
public static void arg_enableConsole()
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel;
|
||||
using System.Net.Http;
|
||||
using Newtonsoft.Json;
|
||||
using WeeXnes.Views.ProfileView;
|
||||
using WeeXnes.Views.Settings;
|
||||
using Wpf.Ui.Appearance;
|
||||
using Wpf.Ui.Controls;
|
||||
|
@ -73,10 +74,12 @@ namespace WeeXnes.Core
|
|||
_token = token;
|
||||
return token;
|
||||
//Console.WriteLine($"Token: {token}");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
WeeXnes.Core.CustomConsole.WriteLine("Error: " + response.StatusCode);
|
||||
LoginView.errorStringCache.Value = response.StatusCode.ToString();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -116,6 +119,7 @@ namespace WeeXnes.Core
|
|||
//Console.WriteLine($"Email: {user.email}");
|
||||
// Access other properties as needed
|
||||
_currentUserCache.Value = user;
|
||||
LoginView.alreadyLoggedIn = true;
|
||||
return user;
|
||||
}
|
||||
else
|
||||
|
@ -124,6 +128,8 @@ namespace WeeXnes.Core
|
|||
_currentUserCache.Value = null;
|
||||
|
||||
WeeXnes.Core.CustomConsole.WriteLine("Error: " + response.StatusCode);
|
||||
|
||||
LoginView.errorStringCache.Value = response.StatusCode.ToString();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,13 +91,13 @@
|
|||
Name="ButtonPwGen"
|
||||
PageTag="Gen"
|
||||
PageType="{x:Type passwordGenerator:PasswordGenView}"/>
|
||||
<ui:NavigationItem
|
||||
<ui:NavigationItem
|
||||
Visibility="Collapsed"
|
||||
Content="Profile"
|
||||
Icon="InprivateAccount24"
|
||||
Name="ButtonProfile"
|
||||
PageTag="Profile"
|
||||
PageType="{x:Type profile:ProfileView}"/>
|
||||
PageType="{x:Type profile:LoginView}"/>
|
||||
</ui:NavigationStore.Items>
|
||||
<ui:NavigationStore.Footer>
|
||||
<ui:NavigationItem
|
||||
|
|
15
WeeXnes/Views/ProfileView/LoginError.xaml
Normal file
15
WeeXnes/Views/ProfileView/LoginError.xaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<Page x:Class="WeeXnes.Views.ProfileView.LoginError"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:WeeXnes.Views.ProfileView"
|
||||
mc:Ignorable="d"
|
||||
Title="LoginError" Height="Auto" Width="Auto">
|
||||
<Grid>
|
||||
<StackPanel VerticalAlignment="Center">
|
||||
<Label Content="wrong credentials" HorizontalAlignment="Center" Padding="0,0,0,10"/>
|
||||
<Button Content="Back to login" HorizontalAlignment="Center" Click="ButtonBase_OnClick"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Page>
|
19
WeeXnes/Views/ProfileView/LoginError.xaml.cs
Normal file
19
WeeXnes/Views/ProfileView/LoginError.xaml.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace WeeXnes.Views.ProfileView
|
||||
{
|
||||
public partial class LoginError : Page
|
||||
{
|
||||
public LoginError()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
NavigationService.Navigate(new Uri("/Views/ProfileView/LoginView.xaml",UriKind.Relative));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,8 +5,15 @@
|
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:WeeXnes.Views.ProfileView"
|
||||
mc:Ignorable="d"
|
||||
Title="LoginView" Height="450" Width="800">
|
||||
Title="LoginView" Height="Auto" Width="Auto"
|
||||
Loaded="LoginView_OnLoaded">
|
||||
<Grid>
|
||||
|
||||
<StackPanel>
|
||||
<Label Content="Email:"/>
|
||||
<TextBox Name="tb_email" Margin="0,0,0,10" KeyDown="InputKeydown"/>
|
||||
<Label Content="Password:"/>
|
||||
<TextBox Name="tb_password" Margin="0,0,0,10" KeyDown="InputKeydown"/>
|
||||
<Button Content="Login" HorizontalAlignment="Center" Name="LoginButton" Click="LoginButton_OnClick"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
|
|
@ -1,12 +1,49 @@
|
|||
using System.Windows.Controls;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using WeeXnes.Core;
|
||||
|
||||
namespace WeeXnes.Views.ProfileView
|
||||
{
|
||||
public partial class LoginView : Page
|
||||
{
|
||||
public static bool alreadyLoggedIn = false;
|
||||
public static UpdateVar<string> errorStringCache = new UpdateVar<string>();
|
||||
public LoginView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void SwitchToProfileView()
|
||||
{
|
||||
NavigationService.Navigate(new Uri("/Views/ProfileView/ProfileView.xaml",UriKind.Relative));
|
||||
}
|
||||
|
||||
private void LoginView_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (alreadyLoggedIn)
|
||||
{
|
||||
SwitchToProfileView();
|
||||
}
|
||||
}
|
||||
|
||||
private void LoginButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
attemptLogin();
|
||||
}
|
||||
|
||||
private void InputKeydown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
attemptLogin();
|
||||
}
|
||||
|
||||
private void attemptLogin()
|
||||
{
|
||||
ProfileView.auth._email = tb_email.Text;
|
||||
ProfileView.auth._password = tb_password.Text;
|
||||
SwitchToProfileView();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,13 +16,13 @@ namespace WeeXnes.Views.ProfileView
|
|||
public ProfileView()
|
||||
{
|
||||
InitializeComponent();
|
||||
auth._email = "";
|
||||
auth._password = "";
|
||||
}
|
||||
private void ProfileView_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
auth.ExceptionCache.ValueChanged += LoginWorkerException;
|
||||
auth._currentUserCache.ValueChanged += userCacheChanged;
|
||||
LoginView.errorStringCache.ValueChanged += errorStringChanged;
|
||||
WeeXnes.Core.CustomConsole.WriteLine("Error Hooks loaded");
|
||||
|
||||
WeeXnes.Core.CustomConsole.WriteLine("Event hooks loaded");
|
||||
if (auth._currentUserCache.Value == null)
|
||||
|
@ -32,6 +32,7 @@ namespace WeeXnes.Views.ProfileView
|
|||
}
|
||||
else
|
||||
{
|
||||
LoadProfileToGui();
|
||||
ProfileContentPanel.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
@ -49,8 +50,11 @@ namespace WeeXnes.Views.ProfileView
|
|||
}
|
||||
else
|
||||
{
|
||||
ProfileContentPanel.Visibility = Visibility.Collapsed;
|
||||
LoadingScreen.Visibility = Visibility.Visible;
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
ProfileContentPanel.Visibility = Visibility.Collapsed;
|
||||
LoadingScreen.Visibility = Visibility.Visible;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,8 +80,16 @@ namespace WeeXnes.Views.ProfileView
|
|||
|
||||
auth.ExceptionCache.ValueChanged -= LoginWorkerException;
|
||||
auth._currentUserCache.ValueChanged -= userCacheChanged;
|
||||
LoginView.errorStringCache.ValueChanged -= errorStringChanged;
|
||||
|
||||
WeeXnes.Core.CustomConsole.WriteLine("Event hooks unloaded");
|
||||
}
|
||||
private void errorStringChanged()
|
||||
{
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
NavigationService.Navigate(new Uri("/Views/ProfileView/LoginError.xaml",UriKind.Relative));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<Version>4.4.7</Version>
|
||||
<Version>4.4.8</Version>
|
||||
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>WeeXnes</RootNamespace>
|
||||
|
@ -106,6 +106,9 @@
|
|||
<Compile Include="Views\PasswordGenerator\SaveToKeyManagerView.xaml.cs">
|
||||
<DependentUpon>SaveToKeyManagerView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\ProfileView\LoginError.xaml.cs">
|
||||
<DependentUpon>LoginError.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\ProfileView\LoginView.xaml.cs">
|
||||
<DependentUpon>LoginView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -150,6 +153,7 @@
|
|||
<Page Include="Views\PasswordGenerator\PasswordGenView.xaml" />
|
||||
<Page Include="Views\PasswordGenerator\SavePasswordView.xaml" />
|
||||
<Page Include="Views\PasswordGenerator\SaveToKeyManagerView.xaml" />
|
||||
<Page Include="Views\ProfileView\LoginError.xaml" />
|
||||
<Page Include="Views\ProfileView\LoginView.xaml" />
|
||||
<Page Include="Views\ProfileView\ProfileView.xaml" />
|
||||
<Page Include="Views\Settings\ChangePathsView.xaml" />
|
||||
|
|
Loading…
Add table
Reference in a new issue