} // proc BeginEndConfigurationUser private async Task RefreshUserDataAsync(bool force) { bool UpdateUserData(PrivateUserData userData, IDataRow r) { try { userData.UpdateData(r, force); return(true); } catch (Exception e) { userData.Log.Except(e); userData.Dispose(); return(false); } } // func UpdateUserData using (var ctx = await CreateSystemContextAsync()) { var userData = ctx.GetService <IPpsPrivateDataContext>(); var users = await userData?.CreateSelectorAsync("dbo.serverLogins", throwException : false); if (users != null) { // fetch user list foreach (var u in users) { lock (userList) { var userId = u.GetProperty("ID", 0L); if (userId > 0) { var idx = userList.FindIndex(c => c.Id == userId); if (idx >= 0) { if (!UpdateUserData(userList[idx], u)) { userList.RemoveAt(idx); } } else { var user = new PrivateUserData(this, userId, PrivateUserData.CreateUserIdentity(u)); if (UpdateUserData(user, u)) { userList.Add(user); } } } else { Log.Warn("User ignored (id={userId})."); } } } // foreach } // users != null await ctx.RollbackAsync(); } } // proc RefreshUserData
private void InitUser() { systemUser = new PrivateUserData(this, sysUserId, null); userList = new DEList <PrivateUserData>(this, "tw_users", "User list"); PublishItem(new DEConfigItemPublicAction("refreshUsers") { DisplayName = "user-refresh" }); } // proc InitUser
public PrivateUserDataContext(PrivateUserData privateUser, IIdentity currentIdentity) { this.privateUser = privateUser ?? throw new ArgumentNullException(nameof(privateUser)); this.currentIdentity = currentIdentity ?? throw new ArgumentNullException(nameof(currentIdentity)); if (!currentIdentity.IsAuthenticated) { throw new ArgumentException("Identity is not verified.", nameof(currentIdentity)); } if (this.currentIdentity is WindowsIdentity c) // create a copy for WindowsIdentity { this.currentIdentity = c.Clone(); } } // ctor
public UserData ToUserData() { List <AboutPanel> actualPanels = new List <AboutPanel>(); foreach (RawPanelData panel in panels) { actualPanels.Add(panel.ToAboutPanel()); } PublicUserData publicData = new PublicUserData(username, displayname, partnerStatus, livestream != null, effect, badges, deactivated, actualPanels.ToArray(), avatar, (long)followers["totalCount"], (long)treasureChest["value"], (long)wallet["balance"], (long)wallet["totalEarning"]); PrivateUserData privateData = new PrivateUserData((long)@private.subscribers["totalCount"], @private.email, @private.filterWords, @private.streamKey["key"].ToString()); return(new UserData(publicData, privateData)); }
void reset() { StopAllCoroutines(); firebaseManager.setErrorMessage(""); loginPage.SetActive(true); foreach (TMP_InputField input in loginPage.gameObject.GetComponentsInChildren <TMP_InputField>()) { input.text = ""; } loginPage.SetActive(false); memberInfoPage.SetActive(true); email.text = "Email: "; phoneNumber.text = "(000) 000-0000"; memberName.text = "Name"; classification.text = "Member"; daysAttended.text = "Days Attended: "; totalHours.text = "Total Hours: "; averageAttendance.text = "Average Attendance: "; foreach (Transform program in programsContent.transform) { Destroy(program.gameObject); } memberInfoPage.SetActive(false); messageScreen.SetActive(true); messageScreen.gameObject.GetComponentInChildren <TextMeshProUGUI>().text = "MESSAGE"; messageScreen.SetActive(false); loginPage.SetActive(true); editProfilePage.SetActive(false); unverfiedPage.SetActive(false); memberInfoPage.SetActive(false); gameObject.SetActive(false); firebaseManager.auth.SignOut(); firebaseManager.disableLoadingScreen(); mainScreen.SetActive(true); mainScreen.GetComponent <MainScreenManager>().Start(); publicData = null; privateData = null; attendanceData = null; }
void reset() { firebaseManager.setErrorMessage(""); StopAllCoroutines(); screenID = 0; firstTimeEntry = true; foreach (GameObject page in pages) { page.SetActive(true); foreach (TMP_InputField input in page.GetComponentsInChildren <TMP_InputField>()) { input.text = ""; } page.SetActive(false); } pages[0].SetActive(true); update = false; firstTimeEntry = true; inputFields = null; currentPage = null; publicUserData = null; privateUserData = null; programs = new List <string>(); pages[5].SetActive(true); foreach (Transform child in programsContent.transform) { Destroy(child.gameObject); } pages[5].SetActive(false); firebaseManager.disableLoadingScreen(); firebaseManager.auth.SignOut(); gameObject.SetActive(false); mainScreen.SetActive(true); mainScreen.GetComponent <MainScreenManager>().Start(); homeButton.SetActive(true); }
public IEnumerator PushUserToFirebase() { firebaseManager.enableLoadingScreen(); Firebase.Auth.FirebaseUser newUser = null; bool done = false; string errorMessage = ""; publicUserData = new PublicUserData(programs, inspirencEmail.text, school.text, memberName.text, "Member", Int32.Parse(grade.text)); privateUserData = new PrivateUserData(personalEmail.text, address.text, parent1name.text, parent1email.text, parent1number.text, parent2name.text, parent2email.text, parent2number.text, phoneNumber.text, getCheckedGender(), Int32.Parse(age.text)); firebaseManager.auth.CreateUserWithEmailAndPasswordAsync(publicUserData.inspirencEmail, passwordInput.text.ToString()).ContinueWith(task => { if (task.IsCanceled || task.IsFaulted) { errorMessage = errorMessage = (task.Exception.ToString().Substring(task.Exception.ToString().IndexOf("FirebaseException: ") + 19, task.Exception.ToString().Substring(task.Exception.ToString().IndexOf("FirebaseException: ") + 19).IndexOf(".") + 1));; done = true; return; } else if (task.IsCompleted) { newUser = task.Result; done = true; } }); yield return(new WaitUntil(() => done == true)); done = false; if (errorMessage.Equals("The email address is already in use by another account.")) { firebaseManager.setErrorMessage("The email address is already in use by another account."); yield return(new WaitForSeconds(4)); reset(); yield break; } Firebase.Auth.FirebaseUser user = firebaseManager.auth.CurrentUser; if (user != null) { Firebase.Auth.UserProfile profile = new Firebase.Auth.UserProfile { DisplayName = publicUserData.name }; user.UpdateUserProfileAsync(profile).ContinueWith(task => { if (task.IsCanceled || task.IsFaulted) { return; } done = true; }); } yield return(new WaitUntil(() => done == true)); done = false; Firebase.Auth.FirebaseUser currentUser = firebaseManager.auth.CurrentUser; currentUser.SendEmailVerificationAsync().ContinueWith(task => { done = true; }); yield return(new WaitUntil(() => done == true)); done = false; firebaseManager.reference.Child("Users").Child("Public Data").Child(publicUserData.name).Child(currentUser.UserId).Child("profile").SetRawJsonValueAsync(JsonUtility.ToJson(publicUserData)).ContinueWith(task => { if (task.IsCanceled || task.IsFaulted) { return; } if (task.IsCompleted) { done = true; } }); yield return(new WaitUntil(() => done == true)); done = false; firebaseManager.reference.Child("Users").Child("Private Data").Child(publicUserData.name).Child(currentUser.UserId).Child("profile").SetRawJsonValueAsync(JsonUtility.ToJson(privateUserData)).ContinueWith(task => { if (task.IsCanceled || task.IsFaulted) { return; } if (task.IsCompleted) { done = true; } }); yield return(new WaitUntil(() => done == true)); done = false; firebaseManager.reference.Child("Users").Child("Public Data").Child(publicUserData.name).Child(currentUser.UserId).Child("attendance").SetRawJsonValueAsync(JsonUtility.ToJson(new Attendance())).ContinueWith(task => { if (task.IsCanceled || task.IsFaulted) { return; } if (task.IsCompleted) { done = true; } }); yield return(new WaitUntil(() => done == true)); done = false; firebaseManager.reference.Child("Email List").Child(inspirencEmail.text.Substring(0, inspirencEmail.text.IndexOf("@"))).SetValueAsync(inspirencEmail.text).ContinueWith(task => { if (task.IsCanceled || task.IsFaulted) { return; } if (task.IsCompleted) { done = true; } }); yield return(new WaitUntil(() => done == true)); done = false; firebaseManager.disableLoadingScreen(); }
IEnumerator login(bool isItLoginPage) { bool done = false; bool ableToSignIn = true; string errorMessage = ""; firebaseManager.enableLoadingScreen(); firebaseManager.setErrorMessage(""); firebaseManager.auth.SignOut(); firebaseManager.auth.SignInWithEmailAndPasswordAsync(emailInput.text, passwordInput.text).ContinueWith(task => { if (task.IsFaulted) { errorMessage = (task.Exception.ToString().Substring(task.Exception.ToString().IndexOf("FirebaseException: ") + 19, task.Exception.ToString().Substring(task.Exception.ToString().IndexOf("FirebaseException: ") + 19).IndexOf(".") + 1)); ableToSignIn = false; done = true; return; } if (task.IsCompleted) { done = true; } }); yield return(new WaitUntil(() => done == true)); done = false; firebaseManager.setErrorMessage(errorMessage); if (ableToSignIn == false) { firebaseManager.disableLoadingScreen(); yield break; } loginPage.SetActive(false); if (firebaseManager.auth.CurrentUser.IsEmailVerified == false) { unverfiedPage.SetActive(true); firebaseManager.disableLoadingScreen(); yield break; } memberInfoPage.SetActive(true); if (isItLoginPage == true) { messageScreen.SetActive(true); messageScreen.GetComponentInChildren <TextMeshProUGUI>().text = "Welcome " + firebaseManager.auth.CurrentUser.DisplayName + "!"; yield return(new WaitForSeconds(1)); messageScreen.SetActive(false); } publicData = null; firebaseManager.getFirebaseReference("Users").Child("Public Data").Child(firebaseManager.auth.CurrentUser.DisplayName).Child(firebaseManager.auth.CurrentUser.UserId).Child("profile").GetValueAsync().ContinueWith(task => { if (task.IsCanceled) { return; } if (task.IsFaulted) { print(task.Exception); return; } if (task.IsCompleted) { publicData = JsonUtility.FromJson <PublicUserData>(task.Result.GetRawJsonValue()); } }); yield return(new WaitUntil(() => publicData != null)); done = false; firebaseManager.getFirebaseReference("Users").Child("Private Data").Child(firebaseManager.auth.CurrentUser.DisplayName).Child(firebaseManager.auth.CurrentUser.UserId).Child("profile").GetValueAsync().ContinueWith(task => { if (task.IsCanceled) { return; } if (task.IsFaulted) { return; } if (task.IsCompleted) { privateData = JsonUtility.FromJson <PrivateUserData>(task.Result.GetRawJsonValue()); } }); yield return(new WaitUntil(() => privateData != null)); done = false; firebaseManager.getFirebaseReference("Users").Child("Public Data").Child(firebaseManager.auth.CurrentUser.DisplayName).Child(firebaseManager.auth.CurrentUser.UserId).Child("attendance").GetValueAsync().ContinueWith(task => { if (task.IsCanceled) { return; } if (task.IsFaulted) { return; } if (task.IsCompleted) { attendanceData = JsonUtility.FromJson <Attendance>(task.Result.GetRawJsonValue()); } }); yield return(new WaitUntil(() => attendanceData != null)); done = false; GameObject recyclableGameObject = null; foreach (Transform program in programsContent.transform) { Destroy(program.gameObject); } foreach (string program in publicData.programs) { recyclableGameObject = Instantiate(programTextPrefab, programsContent.transform, false); recyclableGameObject.GetComponent <TextMeshProUGUI>().text = program; } recyclableGameObject = null; email.text = "Email: " + publicData.inspirencEmail + ", " + privateData.personalEmail; phoneNumber.text = "Phone Number: (" + privateData.phoneNumber.Substring(0, 3) + ") " + privateData.phoneNumber.Substring(3, 3) + "-" + privateData.phoneNumber.Substring(6, 4); memberName.text = publicData.name; classification.text = publicData.classification; daysAttended.text = "Days Attended: " + attendanceData.daysAttended.ToString(); totalHours.text = "Total Hours: " + attendanceData.totalHours.ToString(); averageAttendance.text = "Average Hours: " + attendanceData.averageHours.ToString(); firebaseManager.disableLoadingScreen(); yield break; }
private void signup_button_Click(object sender, EventArgs e) { ProfileUserData profile = new ProfileUserData() { Username = username_textbox.Text, ProfilePhoto = profile_image_picturebox.Image }; PrivateUserData @private = new PrivateUserData() { Name = name_textbox.Text, Surname = surname_textbox.Text, Password = password_textbox.Text, Email = email_textbox.Text }; EditableUserData data = new EditableUserData { Profile = profile, Private = @private }; #region rubbish /*if (DataServerDialog.Dialog.State != ConnectionState.Connected) * { * MessageBox.Show("No connection"); * } * else if (DataServerDialog.Dialog.SendMessage("SIGNUP", ("EditableData", editable))) * { * this.Invoke((MethodInvoker)delegate * { * signup_button.Text = "Connecting..."; * signup_button.Enabled = false; * ReversiSerializableTypes.Message message = DataServerDialog.Dialog.ReceiveMessage(); * signup_button.Text = "Register"; * signup_button.Enabled = true; * * MessageBox.Show((string)message.Payload["description"], message.Title); * if (message.Title == "SUCCESS") * { * this.Close(); * } * }); * * }*/ #endregion void unmark_waiting() { this.signup_button.Invoke((MethodInvoker)(() => { signup_button.Text = "Register"; signup_button.Enabled = true; this.Cursor = Cursors.Default; })); } Servers.DataServer.SignUp(data, new ServerDialog.Reactions { RequestSentCallback = () => { signup_button.Invoke((MethodInvoker)(() => { signup_button.Text = "Waiting..."; signup_button.Enabled = false; })); }, MessageReceivedCallback = (message) => { unmark_waiting(); this.Invoke((MethodInvoker)(() => { if (message.Title == "SUCCESS") { this.Close(); } else { info1.Show(); info1.Text = (string)message.Payload["description"]; } })); }, DisconnectionErrorCallback = () => { unmark_waiting(); this.Invoke((MethodInvoker)(() => { info1.Show(); info1.Text = "Connection error"; })); } }); }