Feat : UserAuth & User load Save
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
5f4051d56f
commit
405e77cbf3
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Stim.Create"
|
||||
Title="Create">
|
||||
<Grid BackgroundColor="{StaticResource Tertiary}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="5*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
||||
<VerticalStackLayout BackgroundColor="Black" Grid.Column="0"/>
|
||||
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2"/>
|
||||
<VerticalStackLayout BackgroundColor="Black" Grid.Column="0" Grid.Row="1"/>
|
||||
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2" Grid.Row="1"/>
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="4*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Image Source="no_cover.png"/>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<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 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="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Text="Se connecter" Clicked="Se_connecter" HeightRequest="50" BackgroundColor="{StaticResource Gray500}"/>
|
||||
<Button Text="Créer un compte" Clicked="Creer_un_compte" HeightRequest="50" BackgroundColor="{StaticResource Gray500}" Grid.Column="1"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ContentPage>
|
@ -0,0 +1,33 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Stim;
|
||||
|
||||
public partial class Create : ContentPage
|
||||
{
|
||||
public Create()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private async void Creer_un_compte(object sender, EventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(Username.Text) || !string.IsNullOrWhiteSpace(Pswd.Text) || !string.IsNullOrWhiteSpace(Email.Text))
|
||||
{
|
||||
if (((App)App.Current).Manager.SearchUser(Username.Text) == null)
|
||||
{
|
||||
Regex rg = new Regex("^(?=.*[A-Za-z])(?=.*[0-9@$!%*#?&])[A-Za-z-0-9@$!%*#?&]{8,}$");
|
||||
if (rg.IsMatch(Pswd.Text))
|
||||
{
|
||||
((App)App.Current).Manager.AddUsertoUserList(new("", Username.Text, "", Email.Text, Pswd.Text));
|
||||
((App)App.Current).Manager.CurrentUser = ((App)App.Current).Manager.SearchUser(Username.Text);
|
||||
await Navigation.PushAsync(new MainPage());
|
||||
}
|
||||
else throw new NotImplementedException();
|
||||
}
|
||||
else throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
private async void Se_connecter(object sender, EventArgs e)
|
||||
{
|
||||
await Navigation.PushAsync(new LoginPage());
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Stim.LoginPage"
|
||||
Title="LoginPage">
|
||||
<Grid BackgroundColor="{StaticResource Tertiary}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="5*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
||||
<VerticalStackLayout BackgroundColor="Black" Grid.Column="0"/>
|
||||
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2"/>
|
||||
<VerticalStackLayout BackgroundColor="Black" Grid.Column="0" Grid.Row="1"/>
|
||||
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2" Grid.Row="1"/>
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="4*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Image Source="no_cover.png"/>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Entry Placeholder="Username" PlaceholderColor="{StaticResource Primary}" IsPassword="False" x:Name="Username" HeightRequest="50" ClearButtonVisibility="WhileEditing"/>
|
||||
<Entry Placeholder="Mot de passe" PlaceholderColor="{StaticResource Primary}" IsPassword="True" x:Name="Pswd" HeightRequest="50" Grid.Row="1" ClearButtonVisibility="WhileEditing"/>
|
||||
<Grid Grid.Row="2" Margin="10,0,0,10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Text="Se connecter" Clicked="Se_connecter" HeightRequest="50" BackgroundColor="{StaticResource Gray500}"/>
|
||||
<Button Text="Créer un compte" Clicked="Creer_un_compte" HeightRequest="50" BackgroundColor="{StaticResource Gray500}" Grid.Column="1"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ContentPage>
|
@ -0,0 +1,39 @@
|
||||
//using Microsoft.UI.Xaml.Navigation;
|
||||
using Model;
|
||||
|
||||
namespace Stim;
|
||||
|
||||
public partial class LoginPage : ContentPage
|
||||
{
|
||||
public LoginPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private async void Se_connecter(object sender, EventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(Username.Text) || !string.IsNullOrWhiteSpace(Pswd.Text))
|
||||
{
|
||||
User user = ((App)App.Current).Manager.SearchUser(Username.Text);
|
||||
if (user != null)
|
||||
{
|
||||
if (user.Password == Pswd.Text)
|
||||
{
|
||||
((App)App.Current).Manager.CurrentUser = user;
|
||||
await Navigation.PushAsync(new MainPage());
|
||||
}
|
||||
|
||||
else throw new NotImplementedException();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void Creer_un_compte(object sender, EventArgs e)
|
||||
{
|
||||
await Navigation.PushAsync(new Create());
|
||||
}
|
||||
}
|
Loading…
Reference in new issue