public static async Task Logout(ListsActivity thisActivity) { if (AppData.auth.CurrentUser == null) { return; } AppData.auth.SignOut(); AlertShow.Show(thisActivity, "Logged out", "You are now in offline mode"); //reload everything await thisActivity.ReloadListView(); }
public static async Task Login(ListsActivity thisActivity, string inpEmail, string inpPassword) { await AppData.auth.SignInWithEmailAndPasswordAsync(inpEmail, inpPassword); UserClass newLocalUser = new UserClass() { Name = AppData.auth.CurrentUser.DisplayName, Email = AppData.auth.CurrentUser.Email, Uid = AppData.auth.CurrentUser.Uid }; SetLocalUser.Set(newLocalUser); AlertShow.Show(thisActivity, "Welcome " + newLocalUser.Name, "You can now share your lists online"); await thisActivity.ReloadListView(); }
public static async Task Register(ListsActivity thisActivity, string name, string email, string password) { await AppData.auth.CreateUserWithEmailAndPasswordAsync(email, password); var profileUpdate = new UserProfileChangeRequest.Builder() .SetDisplayName(name) .Build(); AppData.auth.CurrentUser.UpdateProfile(profileUpdate); UserClass localUser = new UserClass() { Name = name, Email = email, Uid = AppData.auth.CurrentUser.Uid }; SetLocalUser.Set(localUser); await AppData.usersNode .Child(AppData.auth.CurrentUser.Uid) .PutAsync(localUser); foreach (GroceryListClass any in AppData.currentLists) { if (any.Owner.Uid == AppData.currentUser.Uid) { SaveListOnCloud.Save(any); } } AlertShow.Show(thisActivity, "Welcome " + AppData.currentUser.Name, "You are now registered online and can share your lists with your friends"); await thisActivity.ReloadListView(); }
public static async Task Invite(Activity thisActivity, GroceryListClass toList, string inputEmailAddress) { UserClass inviteeUser = null; UserClass ownerUser = toList.Owner; var allUserData = await AppData.usersNode.OnceAsync <UserClass>(); foreach (FirebaseObject <UserClass> any in allUserData) { if (inputEmailAddress == any.Object.Email) { inviteeUser = any.Object; goto UserExists; } } AlertShow.Show(thisActivity, "No Such User", "The email address you have provided, does not have an account"); return; UserExists: InvitationClass thisInvite = new InvitationClass() { Name = toList.Name, Owner = ownerUser }; //unique userID and the name of the list string invitationTitle = ownerUser.Uid + "|" + toList.Name; await AppData.usersNode.Child(inviteeUser.Uid) .Child("Invitations") .Child(invitationTitle) .PutAsync(thisInvite); AlertShow.Show(thisActivity, "Success", "You have successfully invited " + inviteeUser.Name + " to this List"); }