first login working

pull/60/head
Alexandre AGOSTINHO 2 years ago
parent f863b61358
commit dd93267af8

@ -14,7 +14,7 @@ namespace Views
public Home() public Home()
{ {
Master.User.LogIn("pedrosamigos@hotmail.com", "pamigos"); // Master.User.LogIn("pedrosamigos@hotmail.com", "pamigos");
if (Master.User.CurrentConnected is null) if (Master.User.CurrentConnected is null)
{ {
_recipesDisplayed = Master.Recipe.GetAllRecipes(); _recipesDisplayed = Master.Recipe.GetAllRecipes();

@ -1,3 +1,4 @@
using AppException;
using Model; using Model;
namespace Views; namespace Views;
@ -14,13 +15,29 @@ public partial class Login : ContentPage
private void LoginButton_Clicked(object sender, EventArgs e) 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)
{
try
{ {
DisplayAlert("Wrong informations", "No mail or an incorrect password have been entered.", "OK"); usermgr.AddUserToData(usermgr.CreateUser(mail, password));
} }
else 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(); Navigation.PopModalAsync();
} }
} }

Loading…
Cancel
Save