LogIn.xaml.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace WinUI.OnboardProcess
  16. {
  17. /// <summary>
  18. /// Interaction logic for LogIn.xaml
  19. /// </summary>
  20. public partial class LogIn : UserControl, ISwitchable
  21. {
  22. public LogIn()
  23. {
  24. InitializeComponent();
  25. }
  26. public void UtilizeState(object state)
  27. {
  28. throw new NotImplementedException();
  29. }
  30. public void LoginButton_Click(object sender, RoutedEventArgs e)
  31. {
  32. DoLogin();
  33. }
  34. public void BackButton_Click(object sender, RoutedEventArgs e)
  35. {
  36. Switcher.Switch(new RegisterOrLogIn());
  37. }
  38. private async void DoLogin()
  39. {
  40. CentralAPI api = CentralAPI.Instance;
  41. bool didLogIn = await api.Login(EmailAddressTextBox.Text, PasswordTextBox.Password.ToString(), false);
  42. if (didLogIn)
  43. {
  44. Switcher.Switch(new CreateOrJoin());
  45. }
  46. else
  47. {
  48. ErrorText.Content = "Invalid username or password";
  49. }
  50. }
  51. }
  52. }