first login working

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

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

@ -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();
}
}

Loading…
Cancel
Save