diff --git a/Sources/Stim.Model/User.cs b/Sources/Stim.Model/User.cs index 553e3f8..00e35d7 100644 --- a/Sources/Stim.Model/User.cs +++ b/Sources/Stim.Model/User.cs @@ -46,7 +46,7 @@ namespace Model get => email; set { - Regex rg_email = new Regex("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$"); + Regex rg_email = new Regex("^([a-zA-Z0-9_-]+[.])*[a-zA-Z0-9_-]+@([a-zA-Z0-9_-]+[.])+[a-zA-Z0-9_-]{2,4}$"); if (!(string.IsNullOrWhiteSpace(value)) && rg_email.IsMatch(value)) { email = value; diff --git a/Sources/Stim/Create.xaml.cs b/Sources/Stim/Create.xaml.cs index b317763..2ca4b5d 100644 --- a/Sources/Stim/Create.xaml.cs +++ b/Sources/Stim/Create.xaml.cs @@ -16,7 +16,7 @@ public partial class Create : ContentPage { if (((App)App.Current).Manager.SearchUser(Username.Text) == null) { - Regex rg = new Regex("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$"); + Regex rg = new Regex("^([a-zA-Z0-9_-]+[.])*[a-zA-Z0-9_-]+@([a-zA-Z0-9_-]+[.])+[a-zA-Z0-9_-]{2,4}$"); if (rg.IsMatch(Email.Text)) { rg = new Regex("^(?=.*[A-Za-z])(?=.*[0-9@$!%*#?&])[A-Za-z-0-9@$!%*#?&]{8,}$"); diff --git a/Sources/Stim/LoginPage.xaml b/Sources/Stim/LoginPage.xaml index c3be651..6732ae0 100644 --- a/Sources/Stim/LoginPage.xaml +++ b/Sources/Stim/LoginPage.xaml @@ -1,69 +1,71 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + diff --git a/Sources/Stim/ProfilPage.xaml.cs b/Sources/Stim/ProfilPage.xaml.cs index e972262..1b26846 100644 --- a/Sources/Stim/ProfilPage.xaml.cs +++ b/Sources/Stim/ProfilPage.xaml.cs @@ -1,11 +1,11 @@ using CommunityToolkit.Maui.Views; using Model; +using System.Text.RegularExpressions; namespace Stim; public partial class ProfilPage : ContentPage { - delegate string delegatePopUp(); public ProfilPage() { InitializeComponent(); @@ -23,8 +23,29 @@ public partial class ProfilPage : ContentPage if (string.IsNullOrWhiteSpace(newName as string)) await this.ShowPopupAsync(new MessagePopup("Nom d'utilisateur invalide")); else ((App)App.Current).Manager.CurrentUser.Username = (newName as string); } - void PopUp(object sender, EventArgs e) + public async void PopUpUsername(object sender, EventArgs e) { - //handle method here + var newName = await this.ShowPopupAsync(new EntryPopup("Username")); + if (string.IsNullOrWhiteSpace(newName as string)) await this.ShowPopupAsync(new MessagePopup("Nom d'utilisateur invalide")); + else ((App)App.Current).Manager.CurrentUser.Username = (newName as string); + } + public async void PopUpBio(object sender, EventArgs e) + { + var newBio = await this.ShowPopupAsync(new EntryPopup("Biographie")); + ((App)App.Current).Manager.CurrentUser.Biographie = (newBio as string); + } + public async void PopUpPswd(object sender, EventArgs e) + { + Regex rg = new Regex("^(?=.*[A-Za-z])(?=.*[0-9@$!%*#?&])[A-Za-z-0-9@$!%*#?&]{8,}$"); + var newPswd = await this.ShowPopupAsync(new EntryPopup("Password")); + if (string.IsNullOrWhiteSpace(newPswd as string) || rg.IsMatch(newPswd as string)) await this.ShowPopupAsync(new MessagePopup("Nom d'utilisateur invalide")); + else ((App)App.Current).Manager.CurrentUser.Password = (newPswd as string); + } + public async void PopUpEmail(object sender, EventArgs e) + { + Regex rg = new Regex("^([a-zA-Z0-9_-]+[.])*[a-zA-Z0-9_-]+@([a-zA-Z0-9_-]+[.])+[a-zA-Z0-9_-]{2,4}$"); + var newMail = await this.ShowPopupAsync(new EntryPopup("Email")); + if (string.IsNullOrWhiteSpace(newMail as string) || rg.IsMatch(newMail as string)) await this.ShowPopupAsync(new MessagePopup("Email Invalide")); + else ((App)App.Current).Manager.CurrentUser.Email = (newMail as string); } } \ No newline at end of file diff --git a/Sources/Stim/UserInfo.xaml b/Sources/Stim/UserInfo.xaml index 1611420..2349dba 100644 --- a/Sources/Stim/UserInfo.xaml +++ b/Sources/Stim/UserInfo.xaml @@ -9,10 +9,10 @@ - -