Beispiel #1
0
        private async void btnSignUp_Click(object sender, EventArgs e)
        {
            if (dropMonth.selectedValue == "MM" || dropDay.selectedValue == "DD" || dropYear.selectedValue == "YYYY")
            {
                lblBDError.Visible = true;
            }
            else if (lblUNError.Visible == false && lblEmailError.Visible == false && lblPWError.Visible == false)
            {
                CognitoHelper cognitoHelper = new CognitoHelper();

                try
                {
                    string birthday = dropYear.selectedValue + "-" + dropMonth.selectedValue + "-" + dropDay.selectedValue;
                    bool   success  = await cognitoHelper.SignUpUser(txtUsername.Text, txtPassword.Text, txtEmail.Text, birthday);

                    if (success)
                    {
                        VerificationCode verificationCode      = new VerificationCode(txtUsername.Text);
                        Point            verificationcodePoint = new Point(281, 162);

                        verificationCode.Location = verificationcodePoint;
                        verificationCode.Show();
                        Program.home.Controls.Add(verificationCode);

                        this.Dispose();
                    }
                    else
                    {
                        MessageBox.Show("some unhandled error");
                    }
                }
                catch (Amazon.CognitoIdentityProvider.Model.UsernameExistsException)
                {
                    lblUNError.Visible = true;
                    lblUNError.Text    = "Username already exists";
                }
                catch (Amazon.CognitoIdentityProvider.Model.AliasExistsException)
                {
                    lblUNError.Visible = true;
                    lblUNError.Text    = "Username already exists";
                }
                catch (Amazon.CognitoIdentityProvider.Model.InvalidParameterException)
                {
                    lblEmailError.Visible = true;
                    lblEmailError.Text    = "Invalid email";
                }
                catch (Exception)
                {
                    lblUNError.Visible = true;
                    lblUNError.Text    = "Unhandled exception";
                }
            }
        }
Beispiel #2
0
        private async void button1_Click(object sender, EventArgs e)
        {
            CognitoHelper helper  = new CognitoHelper();
            bool          success = await helper.SignUpUser(txtUsername.Text, txtPassword.Text, txtEmail.Text, txtPhone.Text);

            if (success)
            {
                MessageBox.Show("User Added Successfully! Please validate the phone number.");
                CodeEntry codeEntry = new CodeEntry(txtUsername.Text, txtPhone.Text);
                codeEntry.ShowDialog();
            }
            else
            {
                MessageBox.Show("Unable to add the user");
            }
        }