You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.0 KiB
45 lines
1.0 KiB
using AppException;
|
|
using Model;
|
|
|
|
namespace Views;
|
|
|
|
public partial class Login : ContentPage
|
|
{
|
|
MasterManager Master => (Application.Current as App).Master;
|
|
|
|
public Login()
|
|
{
|
|
InitializeComponent();
|
|
BindingContext = Master.User;
|
|
}
|
|
|
|
private void LoginButton_Clicked(object sender, EventArgs e)
|
|
{
|
|
string mail = login_entry.Text;
|
|
string password = passwd_entry.Text;
|
|
var usermgr = Master.User;
|
|
|
|
if (firstLogin_checkbox.IsChecked)
|
|
{
|
|
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();
|
|
}
|
|
}
|
|
}
|