Пример #1
0
        protected void GetSecurityQuestions()
        {
            // get the security questions
            string email  = TBEmail.Text;
            int    userId = proxy.GetUserIdFromEmail(email);

            // load questions
            questionsFromDb = proxy.GetSecurityQuestions(userId);
        }
Пример #2
0
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            string warning = "";

            string email = TBEmail.Text;

            // if nothing in the textbox
            if (string.IsNullOrWhiteSpace(email))
            {
                warning            = "Enter your email. ";
                LblWarning.Visible = true;
                LblWarning.Text    = warning;
                return;
            }
            int userId = proxy.GetUserIdFromEmail(email);

            // if there is no email found
            if (userId < 0)
            {
                warning            = "Email not found. ";
                LblWarning.Visible = true;
                LblWarning.Text    = warning;
                return;
            }
            else   // if there is a userId for this email
            {
                // hide warning
                LblWarning.Visible = false;

                // Verify account
                bool verified = proxy.VerifyAccount(userId);

                // if verified successfully
                if (verified)
                {
                    // show success message
                    LblSuccess.Visible = true;
                    LblSuccess.Text    = "Verified account successfully. ";
                    // show go to login button
                    BtnRedirectToLogin.Visible = true;
                }
                else   // not verified
                {
                    warning            = "Failed to verify email. ";
                    LblWarning.Visible = true;
                    LblWarning.Text    = warning;
                }
            }


            return;
        }
Пример #3
0
        protected bool AddSecurityQuestions()
        {
            string email = TBEmail.Text;
            // get security question and answer
            string question1 = DDLSecurityQuestion1.SelectedValue.ToString();
            string answer1   = TBSecurityQuestion1.Text;

            string question2 = DDLSecurityQuestion2.SelectedValue;
            string answer2   = TBSecurityQuestion2.Text;

            string question3 = DDLSecurityQuestion3.SelectedValue;
            string answer3   = TBSecurityQuestion3.Text;



            // get user id
            int userId = proxy.GetUserIdFromEmail(email);

            if (userId == -1) // if no userId, can't find user Id
            {
                return(false);
            }


            // insert security questions

            bool insert1 = AddSecurityQuestion(userId, question1, answer1);
            bool insert2 = AddSecurityQuestion(userId, question2, answer2);
            bool insert3 = AddSecurityQuestion(userId, question3, answer3);

            // if all inserted
            if (insert1 && insert2 && insert3)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }