Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["mail"] == "true" && Request.QueryString["uname"] != null)
            {
            }
            else if ((Session["Username"] == null && Session["Guest"] == null && Request.QueryString["mail"] == null) || (Session["Username"] == null && Session["Guest"] == null && Request.QueryString["mail"] != null))
            {
                Response.Redirect("Login.aspx");
            }
            else if ((Session["Guest"] != null || Session["Username"] != null) && Request.QueryString["mail"] == null)
            {
                Response.Redirect("Home.aspx");
            }
            else if (Session["Guest"] != null && Request.QueryString["mail"] != null)
            {
                Response.Redirect("Home.aspx");
            }

            string username;
            string mail = Request.QueryString["mail"].ToString();

            if (mail == "true")
            {
                if (Request.QueryString["uname"] == null)
                {
                    Response.Redirect("Verification.aspx?mail=false");
                }
                pAppVerify.Visible = false;
                btnLogout.Visible  = false;
                pVerified.Visible  = false;
                btnLogin.Visible   = false;
                username           = Request.QueryString["uname"].ToString();
            }
            else
            {
                pEmailVerify.Visible  = false;
                btnVerifyUser.Visible = false;
                pVerified.Visible     = false;
                btnLogin.Visible      = false;
                username = Session["Username"].ToString();
            }
            h5Username.InnerText = "Username: "******"Username"] != null)
            {
                Response.Redirect("Home.aspx");
            }
        }
Esempio n. 2
0
        protected void btnEditProfile_Click(object sender, EventArgs e)
        {
            string username = Session["Username"].ToString();

            UserService.UserService proxy = new UserService.UserService();
            UserService.User        user  = proxy.GetUser(username);
            string[] questions            = user.SecretQuestions.Split(',');
            string[] answers = user.SecretAnswers.Split(',');
            txtUsername.Text           = user.Username;
            txtFirstName.Text          = user.FirstName;
            txtLastName.Text           = user.LastName;
            txtHomeAddress.Text        = user.HomeAddress;
            txtBillingAddress.Text     = user.BillingAddress;
            txtImage.Text              = user.ProfileImage;
            txtPhone.Text              = user.Phone;
            txtSecurity1.Text          = answers[0];
            txtSecurity2.Text          = answers[1];
            txtSecurity3.Text          = answers[2];
            ddlSecurity1.SelectedValue = questions[0];
            ddlSecurity2.SelectedValue = questions[1];
            ddlSecurity3.SelectedValue = questions[2];

            divMyProfile.Visible     = false;
            divUpdateProfile.Visible = true;
            divPostContainer.Visible = false;
        }
Esempio n. 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["Username"] == null && Session["Guest"] == null)
     {
         Response.Redirect("Login.aspx");
     }
     if (Session["Username"] != null)
     {
         lblUserInfo.Text    = "@" + Session["Username"].ToString();
         lnkBtnLogin.Visible = false;
         string username = Session["Username"].ToString();
         UserService.UserService proxy = new UserService.UserService();
         bool verified = proxy.IsUserVerified(username);
         if (!verified)
         {
             Response.Redirect("Verification.aspx?mail=false");
         }
     }
     if (Session["Guest"] != null)
     {
         lnkBtnLogout.Visible = false;
         lnkMyProfile.Visible = false;
         lblUserInfo.Visible  = false;
         lnkPMs.Visible       = false;
     }
     InitializeWebAssets();
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Username"] == null && Session["Guest"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            if (Session["Guest"] != null)
            {
                Response.Redirect("Home.aspx");
            }
            if (Session["Username"] != null)
            {
                currentUsername = Session["Username"].ToString();
                UserService.UserService proxy = new UserService.UserService();
                bool verified = proxy.IsUserVerified(currentUsername);
                if (!verified)
                {
                    Response.Redirect("Verification.aspx?mail=false");
                }
            }

            List <TwitterClassLibrary.Models.PrivateMessage> usersPms = new List <TwitterClassLibrary.Models.PrivateMessage>();

            usersPms = DBSerialize.ReadSerializedPM(currentUsername);
            if (usersPms.Count == 0)
            {
                lblRepeaterMessage.Text = "You don't have any private messages!";
            }
            else
            {
                repeaterPMs.DataSource = usersPms;
                repeaterPMs.DataBind();
            }
        }
Esempio n. 5
0
        protected void btnUpdatePassword_Click(object sender, EventArgs e)
        {
            string username = Session["UsernameRetrieve"].ToString();
            string password = txtNewPassword.Text;

            if (password == "")
            {
                smlNewPasswordHelp.InnerText = "Please enter a valid password";
                return;
            }
            else
            {
                smlNewPasswordHelp.InnerText = "";
            }

            UserService.UserService proxy = new UserService.UserService();
            bool updatePW = proxy.UpdatePassword(username, TwitterClassLibrary.Encryption.PasswordEncryption.EncryptPassword(password));

            if (!updatePW)
            {
                smlNewPasswordHelp.InnerText = "Password update failed, contact developers";
                return;
            }
            else
            {
                smlNewPasswordHelp.InnerText = "";
                Response.Redirect("Login.aspx");
            }
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Username"] == null && Session["Guest"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            if (Session["Username"] != null)
            {
                string username = Session["Username"].ToString();
                UserService.UserService proxy = new UserService.UserService();
                bool verified = proxy.IsUserVerified(username);
                if (!verified)
                {
                    Response.Redirect("Verification.aspx?mail=false");
                }
            }

            Exception ex = null;

            if (Session["Username"] != null)
            {
                currentUsername = (string)Session["Username"];
                List <(string, dynamic, Type)> filter = new List <(string, dynamic, Type)>();
                filter.Add(DBObjCreator.CreateFilter("Username", currentUsername, typeof(string)));
                List <object[]> records = DBObjCreator.ReadDBObjsWithWhere("TP_GetUser", ref ex, filter);
                List <User>     newUser = new List <User>();
                records.ForEach(r => newUser.Add(DBObjCreator.CreateObj <User>(r, typeof(User))));
                currentUser = newUser[0];
                Session["CurrentUserObj"] = currentUser;
            }
            if (!IsPostBack)
            {
                Session["AdvSearch"] = false;
                if (Session["Username"] != null)
                {
                    Greeting.InnerText = "All Posts";
                    InitializeTrendingList();
                    InitializeFollowList();
                    InitializeAllPostsList();
                    repeaterFollow.Visible = false;
                    Session["CurrentView"] = ALL;
                }
                if (Session["Guest"] != null)
                {
                    Greeting.InnerText = "All Posts";
                    InitializeAllPostsList();
                    InitializeTrendingList();
                    btnFollowPosts.Visible   = false;
                    Session["CurrentView"]   = ALL;
                    divCreateComment.Visible = false;
                    btnNewPost.Visible       = false;
                }
            }
            SetupPostCardEvents();
        }
Esempio n. 7
0
        protected void btnVerifyUser_Click(object sender, EventArgs e)
        {
            string username = Request.QueryString["uname"].ToString();

            UserService.UserService proxy = new UserService.UserService();
            bool verify = proxy.UpdateUserVerification(username);

            if (verify == true)
            {
                Response.Redirect("Home.aspx");
                Session["Username"] = username;
            }
        }
Esempio n. 8
0
        protected void btnVerifyEmail_Click(object sender, EventArgs e)
        {
            string email = txtVerifyEmail.Text;

            if (email == "")
            {
                smlVerifyEmailHelp.InnerText = "Please enter your email address";
                return;
            }
            else
            {
                smlVerifyEmailHelp.InnerText = "";
            }

            UserService.UserService proxy = new UserService.UserService();
            bool verifyEmail = proxy.ValidateEmail(email);

            if (verifyEmail)
            {
                smlVerifyEmailHelp.InnerText = "Email does not belong to a profile, try again";
                return;
            }
            else
            {
                smlVerifyEmailHelp.InnerText = "";
            }

            UserService.User serviceUser = proxy.GetUserByEmail(email);
            User             recoverUser = new User(serviceUser.Username, serviceUser.FirstName, serviceUser.LastName,
                                                    serviceUser.Password, serviceUser.ProfileImage, serviceUser.HomeAddress, serviceUser.BillingAddress,
                                                    serviceUser.EmailAddress, serviceUser.Phone, serviceUser.SecretQuestions, serviceUser.SecretAnswers, serviceUser.Verified);

            int arrayIndex;
            int secretQuestion = recoverUser.GetRandomQuestion(out arrayIndex);

            lblUsernameSecretQuestion.InnerText = securityQuestions[secretQuestion];

            Session["UsernameRetrieve"] = recoverUser.Username;
            Session["SecretAnswer"]     = recoverUser.GetSecretAnswer(arrayIndex);

            divUsernameSecretQuestion.Visible = true;
        }
Esempio n. 9
0
        protected void lnkDeleteProfile_Click(object sender, EventArgs e)
        {
            string username = Session["Username"].ToString();

            UserService.UserService proxy = new UserService.UserService();
            bool delete = proxy.DeleteUser(username);

            if (!delete)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Profile delete failed, please contact a developer.')", true);
            }
            else
            {
                if (Request.Cookies["Username"] != null)
                {
                    Response.Cookies["Username"].Expires = DateTime.Now.AddDays(-1);
                }
                Session.Abandon();
                Response.Redirect("Login.aspx");
            }
        }
Esempio n. 10
0
        protected void lnkForgotPassword_Click(object sender, EventArgs e)
        {
            string username = txtLogUsername.Text;

            if (username == "")
            {
                smlLogUsernameHelp.InnerText = "Enter your username to retrieve password";
                return;
            }
            else
            {
                smlLogUsernameHelp.InnerText = "";
            }

            UserService.UserService proxy = new UserService.UserService();
            bool verify = proxy.ValidateUsername(username);

            if (verify)
            {
                smlLogUsernameHelp.InnerText = "Username is not registered";
                return;
            }

            UserService.User serviceUser = proxy.GetUser(username);
            User             recoverUser = new User(serviceUser.Username, serviceUser.FirstName, serviceUser.LastName,
                                                    serviceUser.Password, serviceUser.ProfileImage, serviceUser.HomeAddress, serviceUser.BillingAddress,
                                                    serviceUser.EmailAddress, serviceUser.Phone, serviceUser.SecretQuestions, serviceUser.SecretAnswers, serviceUser.Verified);

            int arrayIndex;
            int secretQuestion = recoverUser.GetRandomQuestion(out arrayIndex);

            lblPasswordSecretQuestion.InnerText = securityQuestions[secretQuestion];

            Session["UsernameRetrieve"]  = username;
            Session["RetrievedPassword"] = recoverUser.Password;
            Session["SecretAnswer"]      = recoverUser.GetSecretAnswer(arrayIndex);
            divLogin.Visible             = false;
            divForgotPassword.Visible    = true;
        }
Esempio n. 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Username"] == null && Session["Guest"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            if (Session["Guest"] != null)
            {
                Response.Redirect("Home.aspx");
            }
            if (Session["Username"] != null)
            {
                string username = Session["Username"].ToString();
                UserService.UserService proxy = new UserService.UserService();
                bool verified = proxy.IsUserVerified(username);
                if (!verified)
                {
                    Response.Redirect("Verification.aspx?mail=false");
                }
            }
            if (!IsPostBack)
            {
                string username = Session["Username"].ToString();
                UserService.UserService proxy     = new UserService.UserService();
                UserService.User        proxyUser = proxy.GetUser(username);
                User user = new User(proxyUser.Username, proxyUser.FirstName, proxyUser.LastName, proxyUser.Password,
                                     proxyUser.ProfileImage, proxyUser.HomeAddress, proxyUser.BillingAddress, proxyUser.EmailAddress,
                                     proxyUser.Phone, proxyUser.SecretQuestions, proxyUser.SecretAnswers, proxyUser.Verified);

                imgProfileImage.ImageUrl    = user.ProfileImage;
                lblUsername.InnerText       = user.Username;
                lblFirstName.InnerText      = user.FirstName;
                lblLastName.InnerText       = user.LastName;
                lblEmail.InnerText          = user.EmailAddress;
                lblPhone.InnerText          = user.Phone;
                lblHomeAddress.InnerText    = user.HomeAddress;
                lblBillingAddress.InnerText = user.BillingAddress;
                string[] questions = user.SecretQuestions.Split(',');
                lblSecurityQuestion1.InnerText = securityQuestions[Int32.Parse(questions[0])];
                lblSecurityQuestion2.InnerText = securityQuestions[Int32.Parse(questions[1])];
                lblSecurityQuestion3.InnerText = securityQuestions[Int32.Parse(questions[2])];

                // Getting Posts
                string               url      = "https://localhost:44312/api/User/GetUserPosts/" + username;
                WebRequest           request  = WebRequest.Create(url);
                WebResponse          response = request.GetResponse();
                Stream               stream   = response.GetResponseStream();
                StreamReader         reader   = new StreamReader(stream);
                String               data     = reader.ReadToEnd();
                JavaScriptSerializer js       = new JavaScriptSerializer();

                List <Post> posts = js.Deserialize <List <Post> >(data);

                RepeaterPosts.DataSource = posts;
                RepeaterPosts.DataBind();

                if (posts.Count == 0)
                {
                    h5NoPosts.Visible = true;
                }

                stream.Close();
                reader.Close();

                // Getting Follow count
                string       url2      = "https://localhost:44312/api/Follow/GetFollowCount/" + username;
                WebRequest   request2  = WebRequest.Create(url2);
                WebResponse  response2 = request2.GetResponse();
                Stream       stream2   = response2.GetResponseStream();
                StreamReader reader2   = new StreamReader(stream2);
                String       data2     = reader2.ReadToEnd();

                btnFollowing.Text = "Following " + data2;
                stream2.Close();
                reader2.Close();

                // Getting Follower count
                string       url3      = "https://localhost:44312/api/Follow/GetFollowerCount/" + username;
                WebRequest   request3  = WebRequest.Create(url3);
                WebResponse  response3 = request3.GetResponse();
                Stream       stream3   = response3.GetResponseStream();
                StreamReader reader3   = new StreamReader(stream3);
                String       data3     = reader3.ReadToEnd();

                btnFollowers.Text = data3 + " Followers";
                stream3.Close();
                reader3.Close();
            }

            SetupPostCardEvents();
        }
Esempio n. 12
0
        protected void btnUpdateProfile_Click(object sender, EventArgs e)
        {
            string oldUsername    = Session["Username"].ToString();
            string username       = txtUsername.Text;
            string firstName      = txtFirstName.Text;
            string lastName       = txtLastName.Text;
            string homeAddress    = txtHomeAddress.Text;
            string billingAddress = txtBillingAddress.Text;
            long   phoneNumber;
            string profileImage      = txtImage.Text;
            string securityQuestion1 = txtSecurity1.Text;
            string securityQuestion2 = txtSecurity2.Text;
            string securityQuestion3 = txtSecurity3.Text;
            string secretAnswers     = securityQuestion1 + "," + securityQuestion2 + "," + securityQuestion3;
            string secretQuestions   = ddlSecurity1.SelectedValue + "," + ddlSecurity2.SelectedValue + "," + ddlSecurity3.SelectedValue;
            bool   good = true;

            if (username == "")
            {
                smlUsernameHelp.InnerText = "Please enter a username";
                good = false;
            }
            else
            {
                smlUsernameHelp.InnerText = "";
            }
            if (firstName == "")
            {
                smlFirstNameHelp.InnerText = "Please enter a first name";
                good = false;
            }
            else
            {
                smlFirstNameHelp.InnerText = "";
            }
            if (lastName == "")
            {
                smlLastNameHelp.InnerText = "Please enter a last name";
                good = false;
            }
            else
            {
                smlLastNameHelp.InnerText = "";
            }
            if (homeAddress == "")
            {
                smlHomeAddressHelp.InnerText = "Please enter a home address";
                good = false;
            }
            else
            {
                smlHomeAddressHelp.InnerText = "";
            }
            if (billingAddress == "")
            {
                smlBillingAddressHelp.InnerText = "Please enter a billing address";
                good = false;
            }
            else
            {
                smlBillingAddressHelp.InnerText = "";
            }
            if (!Int64.TryParse(txtPhone.Text, out phoneNumber))
            {
                smlPhoneHelp.InnerText = "Please enter a valid phone number";
                good = false;
            }
            else
            {
                smlPhoneHelp.InnerText = "";
            }
            if (profileImage == "")
            {
                smlImageHelp.InnerText = "Please enter a valid image URL";
                good = false;
            }
            else
            {
                smlImageHelp.InnerText = "";
            }
            if (securityQuestion1 == "")
            {
                smlQuestion1Help.InnerText = "Please enter a question response";
                good = false;
            }
            else
            {
                smlQuestion1Help.InnerText = "";
            }
            if (securityQuestion2 == "")
            {
                smlQuestion2Help.InnerText = "Please enter a question response";
                good = false;
            }
            else
            {
                smlQuestion2Help.InnerText = "";
            }
            if (securityQuestion3 == "")
            {
                smlQuestion3Help.InnerText = "Please enter a question response";
                good = false;
            }
            else
            {
                smlQuestion3Help.InnerText = "";
            }

            if (!good)
            {
                return;
            }

            UserService.UserService proxy = new UserService.UserService();
            bool validateUsername         = proxy.ValidateUsername(username);

            if (!validateUsername && username != Session["Username"].ToString())
            {
                smlUsernameHelp.InnerText = "New username already taken, pick a new one";
                return;
            }
            else
            {
                smlUsernameHelp.InnerText = "";
            }

            UserService.User user1 = new UserService.User();
            user1.Username        = username;
            user1.FirstName       = firstName;
            user1.LastName        = lastName;
            user1.HomeAddress     = homeAddress;
            user1.BillingAddress  = billingAddress;
            user1.Phone           = phoneNumber.ToString();
            user1.ProfileImage    = profileImage;
            user1.SecretQuestions = secretQuestions;
            user1.SecretAnswers   = secretAnswers;


            bool updateUser = proxy.UpdateUser(oldUsername, user1);

            if (!updateUser)
            {
                smlUsernameHelp.InnerText = "User profile update failed, try again later";
                return;
            }
            else
            {
                smlUsernameHelp.InnerText = "";
                Session["Username"]       = username;
                if (Request.Cookies["Username"] != null)
                {
                    Response.Cookies["Username"].Value = username;
                }
            }

//            divMyProfile.Visible = true;
//            divUpdateProfile.Visible = false;
//            divPostContainer.Visible = true;

//            UpdatePanelProfile.Update();
            Response.Redirect("UserProfile.aspx");
        }
        protected void btnSendNewPm_Click(object sender, EventArgs e)
        {
            bool   good     = true;
            string reciever = txtRecipient.Text;

            if (reciever.Equals(currentUsername) || string.IsNullOrEmpty(reciever))
            {
                smlRecipientHelp.InnerText = "Must Have Recipient";
                good = false;
            }
            else
            {
                smlRecipientHelp.InnerText = "";
            }

            UserService.UserService proxy = new UserService.UserService();
            bool validateUsername         = proxy.ValidateUsername(reciever);

            if (validateUsername)
            {
                smlRecipientHelp.InnerText = "Recipient does not exist, check spelling or try a different user";
                good = false;
            }
            else
            {
                smlRecipientHelp.InnerText = "";
            }

            string subject = txtSubject.Text;

            if (string.IsNullOrEmpty(subject))
            {
                smlSubjectHelp.InnerText = "Invalid Subject";
                good = false;
            }
            else
            {
                smlSubjectHelp.InnerText = "";
            }

            string message = taPMText.InnerText;

            if (string.IsNullOrEmpty(message))
            {
                smlTextHelp.InnerText = "Must have a message";
                good = false;
            }
            else
            {
                smlTextHelp.InnerText = "";
            }

            if (!good)
            {
                return;
            }

            TwitterClassLibrary.Models.PrivateMessage pm = new
                                                           TwitterClassLibrary.Models.PrivateMessage(
                0, currentUsername, reciever, DateTime.Now.ToString(), subject, message
                );
            DBSerialize.WriteSerializedPM(pm);
            divComposeNewPM.Visible = false;
            lblNewPmError.Text      = "Message sent.";
        }
Esempio n. 14
0
        protected void btnSubmitLogin_Click(object sender, EventArgs e)
        {
            string username = txtLogUsername.Text;
            string password = txtLogPassword.Text;
            bool   good     = true;

            if (username == "")
            {
                smlLogUsernameHelp.InnerText = "Please enter your username";
                good = false;
            }
            else
            {
                smlLogUsernameHelp.InnerText = "";
            }
            if (password == "")
            {
                smlLogPasswordHelp.InnerText = "Please enter your password";
                good = false;
            }
            else
            {
                smlLogPasswordHelp.InnerText = "";
            }
            if (!good)
            {
                return;
            }

            UserService.UserService proxy = new UserService.UserService();
            bool verify = proxy.ValidateUser(username, password);

            if (!verify)
            {
                smlLogPasswordHelp.InnerText = "Username or password is incorrect, try again";
                return;
            }
            else
            {
                smlLogPasswordHelp.InnerText = "";
            }


            Session["Username"] = txtLogUsername.Text;
            if (chkLoginCookie.Checked)
            {
                Response.Cookies["Username"].Value = txtLogUsername.Text;
            }


            bool verified = proxy.IsUserVerified(username);

            if (!verified)
            {
                Response.Redirect("Verification.aspx?mail=false");
            }
            else
            {
                Response.Redirect("Home.aspx");
            }
        }
Esempio n. 15
0
        protected void btnSubmitRegister_Click(object sender, EventArgs e)
        {
            string username       = txtRegUsername.Text;
            string password       = txtRegPassword.Text;
            string firstName      = txtRegFirstName.Text;
            string lastName       = txtRegLastName.Text;
            string emailAddress   = txtRegEmail.Text;
            string homeAddress    = txtRegHomeAddress.Text;
            string billingAddress = txtRegBillingAddress.Text;
            long   phoneNumber;
            string profileImage      = txtRegImage.Text;
            string securityQuestion1 = txtRegSecurity1.Text;
            string securityQuestion2 = txtRegSecurity2.Text;
            string securityQuestion3 = txtRegSecurity3.Text;
            string secretAnswers     = securityQuestion1 + "," + securityQuestion2 + "," + securityQuestion3;
            string secretQuestions   = ddlSecurity1.SelectedValue + "," + ddlSecurity2.SelectedValue + "," + ddlSecurity3.SelectedValue;
            bool   good = true;

            MD5CryptoServiceProvider hasher = new MD5CryptoServiceProvider();
            string addSalt = string.Concat("ummm salty ", password);

            byte[] hash = hasher.ComputeHash(Encoding.Unicode.GetBytes(addSalt));

            if (username == "")
            {
                smlRegUsernameHelp.InnerText = "Please enter a username";
                good = false;
            }
            else
            {
                smlRegUsernameHelp.InnerText = "";
            }
            if (password == "")
            {
                smlRegPasswordHelp.InnerText = "Please enter a password";
                good = false;
            }
            else
            {
                smlRegPasswordHelp.InnerText = "";
            }
            if (firstName == "")
            {
                smlRegFirstNameHelp.InnerText = "Please enter a first name";
                good = false;
            }
            else
            {
                smlRegFirstNameHelp.InnerText = "";
            }
            if (lastName == "")
            {
                smlRegLastNameHelp.InnerText = "Please enter a last name";
                good = false;
            }
            else
            {
                smlRegLastNameHelp.InnerText = "";
            }
            if (emailAddress == "")
            {
                smlRegEmailHelp.InnerText = "Please enter an email address";
                good = false;
            }
            else
            {
                smlRegEmailHelp.InnerText = "";
            }
            if (homeAddress == "")
            {
                smlRegHomeAddressHelp.InnerText = "Please enter a home address";
                good = false;
            }
            else
            {
                smlRegHomeAddressHelp.InnerText = "";
            }
            if (billingAddress == "")
            {
                smlRegBillingAddressHelp.InnerText = "Please enter a billing address";
                good = false;
            }
            else
            {
                smlRegBillingAddressHelp.InnerText = "";
            }
            if (!Int64.TryParse(txtRegPhone.Text, out phoneNumber))
            {
                smlRegPhoneHelp.InnerText = "Please enter a valid phone number";
                good = false;
            }
            else
            {
                smlRegPhoneHelp.InnerText = "";
            }
            if (profileImage == "")
            {
                smlRegImageHelp.InnerText = "Please enter a valid image URL";
                good = false;
            }
            else
            {
                smlRegImageHelp.InnerText = "";
            }
            if (securityQuestion1 == "")
            {
                smlRegQuestion1Help.InnerText = "Please enter a question response";
                good = false;
            }
            else
            {
                smlRegQuestion1Help.InnerText = "";
            }
            if (securityQuestion2 == "")
            {
                smlRegQuestion2Help.InnerText = "Please enter a question response";
                good = false;
            }
            else
            {
                smlRegQuestion2Help.InnerText = "";
            }
            if (securityQuestion3 == "")
            {
                smlRegQuestion3Help.InnerText = "Please enter a question response";
                good = false;
            }
            else
            {
                smlRegQuestion3Help.InnerText = "";
            }

            if (!good)
            {
                return;
            }

            UserService.UserService proxy = new UserService.UserService();
            bool validateUsername         = proxy.ValidateUsername(username);

            if (!validateUsername)
            {
                smlRegUsernameHelp.InnerText = "Username already taken, pick a new one";
                return;
            }
            else
            {
                smlRegUsernameHelp.InnerText = "";
            }

            bool validateEmail = proxy.ValidateEmail(emailAddress);

            if (!validateEmail)
            {
                smlRegEmailHelp.InnerText = "Email is taken, please try again with a new one";
                return;
            }
            else
            {
                smlRegEmailHelp.InnerText = "";
            }

            try
            {
                MailAddress fromAddress      = new MailAddress("*****@*****.**", "Not Twitter");
                MailAddress toAddress        = new MailAddress(emailAddress, "New User");
                MailMessage verificationMail = new MailMessage(fromAddress.Address, toAddress.Address);
                verificationMail.Subject = "Not Twitter: New Account Verification";
                verificationMail.Body    = "Click this link to verify your new account. http://localhost:62631/Verification.aspx?uname=" + username + "&mail=true";
                SmtpClient client = new SmtpClient();
                client.Host                  = "smtp.gmail.com";
                client.Port                  = 587;
                client.EnableSsl             = true;
                client.UseDefaultCredentials = false;
                client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                client.Credentials           = new NetworkCredential(fromAddress.Address, "ajcqwouuvihbodbc");
                client.Send(verificationMail);
            }
            catch
            {
                smlRegEmailHelp.InnerText = "Invalid email address, try again";
                return;
            }
            smlRegEmailHelp.InnerText = "";

            UserService.User user1 = new UserService.User();
            user1.Username        = username;
            user1.FirstName       = firstName;
            user1.LastName        = lastName;
            user1.Password        = TwitterClassLibrary.Encryption.PasswordEncryption.EncryptPassword(password);
            user1.EmailAddress    = emailAddress;
            user1.HomeAddress     = homeAddress;
            user1.BillingAddress  = billingAddress;
            user1.Phone           = phoneNumber.ToString();
            user1.ProfileImage    = profileImage;
            user1.SecretQuestions = secretQuestions;
            user1.SecretAnswers   = secretAnswers;
            user1.Verified        = "false";


            bool addUser = proxy.AddUser(user1);

            if (!addUser)
            {
                smlRegUsernameHelp.InnerText = "User registration failed, try again later";
                return;
            }
            else
            {
                smlRegUsernameHelp.InnerText = "";
            }

            Session["Username"] = txtRegUsername.Text;
            if (chkRegCookie.Checked)
            {
                Response.Cookies["Username"].Value = txtRegUsername.Text;
            }

            Response.Redirect("Verification.aspx?mail=false");
        }