private async Task <bool> LoginProcedure() { User?user; ValidUserCreateableToken?userCreateableToken; bool navigateToApp = false; if (Email.Validate() && Password.Validate()) { user = await _UserDataStore.GetUserByEmail(Email.Value); if (user is object) { await App.ApplicationManager.SetCredentialsInStorage(user); App.ApplicationManager.CurrentUser = user; navigateToApp = true; } else { navigateToApp = false; } } return(navigateToApp); }
private async Task <bool> CreateNewUserInformation() { User?user; bool isValid; IsBusy = true; bool isCreated = false;; //AddConfirmPasswordValidation(Password); isValid = ValidateEntries(); if (isValid) { // Copy to Entry Model RegisterModel = CopyValuesToRegisterModel(RegisterModel); // Check using email, if not exist create user = await _UserDataStore.GetUserByEmail(RegisterModel.Email); if (user == null) { user = _UserFactory.CreateUser( FullName: RegisterModel.FullName, BirthDate: RegisterModel.BirthDate, Password: RegisterModel.Password, PhoneNumber: RegisterModel.PhoneNumber, Email: RegisterModel.Email ); isCreated = _UserDataStore.AddItem(user); if (isCreated) { await App.ApplicationManager.SetCredentialsInStorage(user); await App.ApplicationManager.SetCurrentUserDataFromSecureStorage(); } else { // Error, cant add // await Application.Current.MainPage.Navigation.PushAsync(new LoginPage()); // Pop Message of error. } } else { // Exist, should go to login page // await Application.Current.MainPage.Navigation.PushAsync(new LoginPage()); // Pop Message Already have an account. } } IsBusy = false; return(isCreated); }