|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
namespace GameAtlas.Views;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
|
|
|
public partial class PageInscription : ContentPage
|
|
|
|
|
{
|
|
|
|
@ -6,4 +7,68 @@ public partial class PageInscription : ContentPage
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void OnSignUpClicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string mail = email.Text;
|
|
|
|
|
string username = pseudo.Text;
|
|
|
|
|
string mdp = password.Text;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(string.IsNullOrWhiteSpace(mail) || string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(mdp))
|
|
|
|
|
{
|
|
|
|
|
await DisplayAlert("Erreur", "Entrez tous les champs", "Ok");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (!Regex.IsMatch(mail, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"))
|
|
|
|
|
{
|
|
|
|
|
await DisplayAlert("Erreur","Email non valide","Ok");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsPasswordStrong(mdp) == false)
|
|
|
|
|
{
|
|
|
|
|
await DisplayAlert("Erreur", "Le mot de passe n'est pas assez fort", "OK");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await Navigation.PushAsync(new PageAcceuil());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool IsPasswordStrong(string password)
|
|
|
|
|
{
|
|
|
|
|
// Vérifier si le mot de passe est assez long
|
|
|
|
|
if (password.Length < 8)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Vérifier si le mot de passe contient au moins une majuscule, une minuscule et un chiffre
|
|
|
|
|
bool hasUppercase = false;
|
|
|
|
|
bool hasLowercase = false;
|
|
|
|
|
bool hasDigit = false;
|
|
|
|
|
|
|
|
|
|
foreach (char c in password)
|
|
|
|
|
{
|
|
|
|
|
if (char.IsUpper(c))
|
|
|
|
|
{
|
|
|
|
|
hasUppercase = true;
|
|
|
|
|
}
|
|
|
|
|
else if (char.IsLower(c))
|
|
|
|
|
{
|
|
|
|
|
hasLowercase = true;
|
|
|
|
|
}
|
|
|
|
|
else if (char.IsDigit(c))
|
|
|
|
|
{
|
|
|
|
|
hasDigit = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return hasUppercase && hasLowercase && hasDigit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|