private void ActionUponUpdateEmailSuccess() { string result = _webHandlerObject.Response; //if the email was ssuccessfully updated, //the six digit verification code is returned by the server script //otherwise the error message is returned if (int.TryParse(result, out int emailVerificationCode) && result.Length == 6) { //change local value of email GlobalSpace.Email = NewEmailTextBox.Text; GlobalSpace.IsEmailVarified = false; GlobalSpace.EmailVerificationCode = emailVerificationCode.ToString(); //send verification email to the new email address MailAddress from = new MailAddress("*****@*****.**"); MailAddress to = new MailAddress(GlobalSpace.Email); SendVerificationEmail(from, to, emailVerificationCode.ToString()); } else { _progressViewerObject.StopProgress(); MessageBox.Show(result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); EnableAllControls(); } }
private void ActionUponEmailVerificationSuccess() { _progressViewerObject.StopProgress(); GlobalSpace.IsEmailVarified = true; string message = "Your email address has been successfully verified. Thank you."; MessageBox.Show(message, "Thank you", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }
private void ActionUponAuthSuccess() { string result = _webHandlerObject.Response; string[] data = result.Split('|'); //if the registration process succeeds, //user's id, an unique server access token and //a cypher key for decryption are retured //otherwise, the error message is returned if (int.TryParse(data[0], out int userId)) { GlobalSpace.Username = UsernameTextBox.Text; GlobalSpace.UserID = userId; GlobalSpace.AccessToken = data[1]; GlobalSpace.CypherKey = StringCipher.Decrypt(data[2], PasswordTextBox.Text); GlobalSpace.Email = StringCipher.Decrypt(data[3], GlobalSpace.CypherKey); GlobalSpace.IsEmailVarified = data[4] == "1" ? true : false; if (RememberMeCheckBox.Checked) { Properties.Settings.Default.Username = UsernameTextBox.Text; Properties.Settings.Default.Password = PasswordTextBox.Text; Properties.Settings.Default.Save(); } GlobalSpace.EmailVerificationCode = data[5]; //if the account has just been registered, //send an email verification code to the user's email if (data[6] == "New User") { MailAddress from = new MailAddress("*****@*****.**"); MailAddress to = new MailAddress(GlobalSpace.Email); SendVerificationEmail(from, to, GlobalSpace.EmailVerificationCode); } else //if exisitng user logging in { //get daily info of this user from database FetchDailyInfo(); } } else { _progressViewerObject.StopProgress(); ShowErrorMessage(result); //enable all controls so that the user can attempt to login again EnableAllControls(); } }