Added backend for login page and more backend for signuppage

pull/1/head
Matheo HERSAN 2 years ago
parent a5d9263fa4
commit a67bc818d2

@ -9,9 +9,9 @@
<Label Text="Se connecter à MapManga" FontSize="Large" Margin="0,0,0,20" TextColor="#FFFFFF"/>
<Entry Placeholder="Email" Margin="0,0,0,10" BackgroundColor="#EFF0F2" TextColor="{StaticResource Black}"/>
<Entry x:Name="emailEntry" Placeholder="Email" Margin="0,0,0,10" BackgroundColor="#EFF0F2" TextColor="{StaticResource Black}"/>
<Entry Placeholder="Mot de passe" IsPassword="True" Margin="0,0,0,20" BackgroundColor="#EFF0F2" TextColor="{StaticResource Black}"/>
<Entry x:Name="passwordEntry" Placeholder="Mot de passe" IsPassword="True" Margin="0,0,0,20" BackgroundColor="#EFF0F2" TextColor="{StaticResource Black}"/>
<Button Text="Se connecter" Clicked="OnLoginClicked" BackgroundColor="{StaticResource Primary }" TextColor="#FFFFFF"/>

@ -1,4 +1,6 @@
namespace MangaMap.Views;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
public partial class loginPage : ContentPage
{
@ -7,8 +9,34 @@ public partial class loginPage : ContentPage
InitializeComponent();
}
private void OnLoginClicked(object sender, EventArgs e)
async void OnLoginClicked(object sender, EventArgs e)
{
//
// Récupération de l'email et du mot de passe entrés
string email = emailEntry.Text;
string password = passwordEntry.Text;
if (string.IsNullOrWhiteSpace(email) ||
string.IsNullOrWhiteSpace(password))
{
await DisplayAlert("Erreur", "Veuillez remplir tous les champs.", "OK");
return;
}
// Vérifier que l'e-mail a la bonne forme
if (!Regex.IsMatch(email, @"^[^@\s]+@[^@\s]+\.[^@\s]+$"))
{
await DisplayAlert("Erreur", "L'e-mail n'est pas valide.", "OK");
return;
}
// Vérification du mot de passe
if (password != "monmotdepasse")
{
DisplayAlert("Erreur", "Le mot de passe entré est incorrect.", "OK");
return;
}
// Redirection vers la page suivante si le mot de passe est correct
Navigation.PushAsync(new homePage());
}
}
}

@ -29,6 +29,12 @@ public partial class signUpPage : ContentPage
return;
}
if (IsPasswordStrong(password) == false)
{
await DisplayAlert("Erreur", "Le mot de passe n'est pas assez fort", "OK");
return;
}
// Vérifier si les mots de passe correspondent
if (password != confirmPassword)
{
@ -42,4 +48,36 @@ public partial class signUpPage : ContentPage
}
}
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…
Cancel
Save