fix : Erreur de login & path entre log et create
continuous-integration/drone/push Build is passing Details

Popup_qui_marche_pas
Jade VAN BRABANDT 2 years ago
parent 31f2e01bc3
commit 3a45082a62

@ -40,7 +40,7 @@ namespace StimPersistance
if (File.Exists("games.xml"))
{
DataContractSerializer serializer = new(typeof(ObservableCollection<Game>));
using (Stream stream = File.OpenRead("games.xml")) return serializer.ReadObject(stream) as ObservableCollection<Game>;
using (Stream stream = File.OpenRead("games.xml")) return serializer.ReadObject(stream) as ObservableCollection<Game> ?? new();
}
return new();
}
@ -50,7 +50,7 @@ namespace StimPersistance
if (File.Exists("users.xml"))
{
DataContractSerializer serializer = new(typeof(HashSet<User>));
using (Stream stream = File.OpenRead("users.xml")) return serializer.ReadObject(stream) as HashSet<User>;
using (Stream stream = File.OpenRead("users.xml")) return serializer.ReadObject(stream) as HashSet<User> ?? new();
}
return new();
}

@ -34,9 +34,9 @@
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Entry Text="Adresse@adresse.com" Placeholder="Adresse Mail" PlaceholderColor="{StaticResource Primary}" IsPassword="False" x:Name="Email" HeightRequest="50" ClearButtonVisibility="WhileEditing"/>
<Entry Placeholder="Adresse Mail" PlaceholderColor="{StaticResource Primary}" IsPassword="False" x:Name="Email" HeightRequest="50" ClearButtonVisibility="WhileEditing"/>
<Entry Placeholder="Username" PlaceholderColor="{StaticResource Primary}" IsPassword="False" x:Name="Username" HeightRequest="50" Grid.Row="1" ClearButtonVisibility="WhileEditing"/>
<Entry Text="Azerty123*" Placeholder="Mot de passe" PlaceholderColor="{StaticResource Primary}" IsPassword="True" x:Name="Pswd" HeightRequest="50" Grid.Row="2" ClearButtonVisibility="WhileEditing"/>
<Entry Placeholder="Mot de passe" PlaceholderColor="{StaticResource Primary}" IsPassword="True" x:Name="Pswd" HeightRequest="50" Grid.Row="2" ClearButtonVisibility="WhileEditing"/>
<Grid Grid.Row="3" Margin="10,0,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
@ -46,6 +46,8 @@
<Button Text="Créer un compte" Clicked="Creer_un_compte" HeightRequest="50" BackgroundColor="{StaticResource Gray500}" Grid.Column="1"/>
</Grid>
</Grid>
<HorizontalStackLayout x:Name="Error" Grid.Row="2">
</HorizontalStackLayout>
</Grid>
</Grid>
</ContentPage>

@ -1,3 +1,4 @@
using Microsoft.Maui.Graphics;
using System.Text.RegularExpressions;
namespace Stim;
@ -10,7 +11,8 @@ public partial class Create : ContentPage
}
private async void Creer_un_compte(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(Username.Text) || !string.IsNullOrWhiteSpace(Pswd.Text) || !string.IsNullOrWhiteSpace(Email.Text))
Error.Clear();
if (!string.IsNullOrWhiteSpace(Username.Text) && !string.IsNullOrWhiteSpace(Pswd.Text) && !string.IsNullOrWhiteSpace(Email.Text))
{
if (((App)App.Current).Manager.SearchUser(Username.Text) == null)
{
@ -22,14 +24,15 @@ public partial class Create : ContentPage
Application.Current.MainPage = new AppShell();
await Shell.Current.GoToAsync("//MainPage");
}
else throw new NotImplementedException();
else Error.Children.Add(new Label { Text = "Mot de passe incorrect", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start });
}
else throw new NotImplementedException();
else Error.Children.Add(new Label { Text = "Ce nom d'utilisateur est déjà pris", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start });
}
else Error.Children.Add(new Label { Text = "Champs vides", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start });
}
private async void Se_connecter(object sender, EventArgs e)
private void Se_connecter(object sender, EventArgs e)
{
//Ca ça marche pas faut une autre commande, Marc svp aide moi
await Navigation.PushAsync(new LoginPage());
Application.Current.MainPage = new LoginPage();
}
}

@ -44,6 +44,9 @@
<Button Text="Créer un compte" Clicked="Creer_un_compte" HeightRequest="50" BackgroundColor="{StaticResource Gray500}" Grid.Column="1"/>
</Grid>
</Grid>
<HorizontalStackLayout x:Name="Error" Grid.Row="2">
</HorizontalStackLayout>
</Grid>
</Grid>
</ContentPage>

@ -1,8 +1,8 @@
//using Microsoft.UI.Xaml.Navigation;
using Model;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Stim;
public partial class LoginPage : ContentPage
{
public LoginPage()
@ -12,7 +12,7 @@ public partial class LoginPage : ContentPage
private async void Se_connecter(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(Username.Text) || !string.IsNullOrWhiteSpace(Pswd.Text))
if (!string.IsNullOrWhiteSpace(Username.Text) && !string.IsNullOrWhiteSpace(Pswd.Text))
{
User user = ((App)App.Current).Manager.SearchUser(Username.Text);
if (user != null)
@ -24,17 +24,16 @@ public partial class LoginPage : ContentPage
await Shell.Current.GoToAsync("//MainPage");
}
else throw new NotImplementedException();
}
else
{
throw new NotImplementedException();
else Error.Children.Add(new Label { Text = "Mot de passe incorrect", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start });
}
else Error.Children.Add(new Label { Text = "Information incorrecte", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start });
}
else Error.Children.Add(new Label { Text = "Champs vides", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start });
}
private async void Creer_un_compte(object sender, EventArgs e)
private void Creer_un_compte(object sender, EventArgs e)
{
await Shell.Current.GoToAsync("//MainPage");
Application.Current.MainPage = new Create();
}
}
Loading…
Cancel
Save