parent
4f1a8c8cec
commit
db94fc7b93
Binary file not shown.
@ -1,9 +1,74 @@
|
|||||||
namespace GameAtlas.Views;
|
namespace GameAtlas.Views;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
public partial class PageInscription : ContentPage
|
public partial class PageInscription : ContentPage
|
||||||
{
|
{
|
||||||
public PageInscription()
|
public PageInscription()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in new issue