Compare commits
No commits in common. "696e4eeb03bf364cdb456817cd7ee66cb8c8ab28" and "c3ca4ec25d18b98190bd0fbde8e1b7d4ac3c193b" have entirely different histories.
696e4eeb03
...
c3ca4ec25d
@ -4,7 +4,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@ -15,6 +14,8 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Net.Http;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace bib_talk
|
||||
{
|
||||
@ -37,10 +38,9 @@ namespace bib_talk
|
||||
DragMove();
|
||||
}
|
||||
}
|
||||
|
||||
private void Login_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Login login = new Login();
|
||||
Login login= new Login();
|
||||
login.Show();
|
||||
this.Close();
|
||||
}
|
||||
@ -48,18 +48,10 @@ namespace bib_talk
|
||||
private void WeiterButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (checkboxAGB.IsChecked == true)
|
||||
{
|
||||
if (ValidateRegistration())
|
||||
{
|
||||
RegisterServer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Bitte akzeptieren Sie die AGB.");
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckBox_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SolidColorBrush customBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF6332A0"));
|
||||
@ -71,48 +63,7 @@ namespace bib_talk
|
||||
{
|
||||
SolidColorBrush customBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF323134"));
|
||||
weiterbutton.Foreground = Brushes.Gray;
|
||||
weiterbutton.Background = customBrush;
|
||||
}
|
||||
|
||||
private bool ValidateRegistration()
|
||||
{
|
||||
string username = usernbox.Text;
|
||||
string password = passwordbox.Password;
|
||||
string email = emailbox.Text;
|
||||
string day = bday1.Text;
|
||||
string month = bday2.Text;
|
||||
string year = bday3.Text;
|
||||
|
||||
// Benutzername validieren
|
||||
if (string.IsNullOrWhiteSpace(username) || username.Length < 3)
|
||||
{
|
||||
MessageBox.Show("Der Benutzername muss mindestens 3 Zeichen lang sein.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Passwort validieren
|
||||
if (string.IsNullOrWhiteSpace(password) || password.Length < 6 || !Regex.IsMatch(password, @"^(?=.*[A-Za-z])(?=.*\d).{6,}$"))
|
||||
{
|
||||
MessageBox.Show("Das Passwort muss mindestens 6 Zeichen lang sein und sowohl Buchstaben als auch Zahlen enthalten.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// E-Mail validieren
|
||||
if (string.IsNullOrWhiteSpace(email) || !Regex.IsMatch(email, @"^[^@\s]+@[^@\s]+\.[^@\s]+$"))
|
||||
{
|
||||
MessageBox.Show("Bitte geben Sie eine gültige E-Mail-Adresse ein.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Geburtsdatum validieren
|
||||
if (!int.TryParse(day, out int dayInt) || !int.TryParse(month, out int monthInt) || !int.TryParse(year, out int yearInt) ||
|
||||
!DateTime.TryParse($"{yearInt}-{monthInt}-{dayInt}", out DateTime birthDate) || birthDate > DateTime.Now.AddYears(-14))
|
||||
{
|
||||
MessageBox.Show("Bitte geben Sie ein gültiges Geburtsdatum ein. Sie müssen mindestens 18 Jahre alt sein.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
weiterbutton.Background= customBrush;
|
||||
}
|
||||
|
||||
public async Task RegisterServer()
|
||||
@ -120,8 +71,8 @@ namespace bib_talk
|
||||
string username = usernbox.Text;
|
||||
string password = passwordbox.Password;
|
||||
string email = emailbox.Text;
|
||||
string birthday = $"{bday1.Text}.{bday2.Text}.{bday3.Text}";
|
||||
var newUser = new { Username = username, Password = password, Email = email, Birthday = birthday, IsOnline = "" };
|
||||
string birthday = bday1.Text+"."+bday2.Text+"."+bday3.Text;
|
||||
var newUser = new { Username = username, Password = password, Email = email, Birthday = birthday, IsOnline = ""};
|
||||
string json = JsonConvert.SerializeObject(newUser);
|
||||
|
||||
using (var client = new HttpClient())
|
||||
@ -131,11 +82,11 @@ namespace bib_talk
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
MessageBox.Show("Registrierung erfolgreich.");
|
||||
MessageBox.Show("Registration Succesful");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Registrierung fehlgeschlagen. " + response);
|
||||
MessageBox.Show("Registration failed."+ response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user