|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
using AppException;
|
|
|
|
|
using Model;
|
|
|
|
|
|
|
|
|
|
namespace Views;
|
|
|
|
@ -14,13 +15,29 @@ public partial class Login : ContentPage
|
|
|
|
|
|
|
|
|
|
private void LoginButton_Clicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!Master.User.LogIn(login_entry.Text, passwd_entry.Text))
|
|
|
|
|
string mail = login_entry.Text;
|
|
|
|
|
string password = passwd_entry.Text;
|
|
|
|
|
var usermgr = Master.User;
|
|
|
|
|
|
|
|
|
|
if (firstLogin_checkbox.IsChecked)
|
|
|
|
|
{
|
|
|
|
|
DisplayAlert("Wrong informations", "No mail or an incorrect password have been entered.", "OK");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
usermgr.AddUserToData(usermgr.CreateUser(mail, password));
|
|
|
|
|
}
|
|
|
|
|
catch (BadMailFormatException)
|
|
|
|
|
{
|
|
|
|
|
DisplayAlert("Bad mail format", "The mail you entered do not respect the format of a mail address.", "Ok");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!usermgr.LogIn(mail, password))
|
|
|
|
|
{
|
|
|
|
|
DisplayAlert("Wrong informations", "Incorrect mail or password have been entered.", "Ok");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Navigation.PopModalAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|