コード例 #1
0
 protected void SignUp_Click(object sender, EventArgs e)
 {
     using (PizzaNightDataContext dc = new PizzaNightDataContext())
     {
         if ((from t in dc.Users where t.EmailAddress.ToLower() == email.Text.ToLower() select t).Count() > 0)
         {
             LoginError.InnerText = "Email already in use. Are you sure you haven't tried this before?";
             LoginError.Visible   = true;
             return;
         }
         else
         {
             Session["email"] = email.Text;
             Response.Redirect("/SignUp");
         }
     }
 }
コード例 #2
0
        private void FillLaserdiscTable()
        {
            using (PizzaNightDataContext dc = new PizzaNightDataContext())
            {
                var tings = (from t in dc.LaserDiscs
                             orderby t.Title
                             select new
                {
                    t.Title,
                    t.Edition
                });

                litCount.Text           = tings.Count().ToString();
                gvLaserdiscs.DataSource = tings;
                gvLaserdiscs.DataBind();
            }
        }
コード例 #3
0
        protected void submit_Click(object sender, EventArgs e)
        {
            //Check for necessary info
            if (string.IsNullOrEmpty(tbPassword.Text) || string.IsNullOrEmpty(tbUsername.Text) || string.IsNullOrEmpty(tbEmail.Text))
            {
                LoginError.InnerText = "PLEASE FILL IN ALL INFO";
                LoginError.Visible   = true;
                return;
            }

            if (tbPassword.Text == tbPasswordCheck.Text)
            {
                using (PizzaNightDataContext dc = new PizzaNightDataContext())
                {
                    if ((from t in dc.Users where t.Username.ToLower() == tbUsername.Text.ToLower() select t).Count() > 0)
                    {
                        LoginError.InnerText = "Username already in use. Try something a bit more original.";
                        LoginError.Visible   = true;
                        return;
                    }

                    if ((from t in dc.Users where t.EmailAddress.ToLower() == tbEmail.Text.ToLower() select t).Count() > 0)
                    {
                        LoginError.InnerText = "Email already in use. Are you sure you haven't tried this before?";
                        LoginError.Visible   = true;
                        return;
                    }

                    //Check to see if it is at least 8 characters
                    //if (tbPassword.Text.Length < 8)
                    //{
                    //    LoginError.InnerText = "Seriously? Less than 8 characters in your password? Try again";
                    //    LoginError.Visible = true;
                    //    return;
                    //}

                    var password       = "";
                    var salt           = "";
                    var hashedPassword = "";

                    password       = tbPassword.Text;
                    salt           = Crypto.GenerateSalt();
                    hashedPassword = Crypto.HashPassword(salt + password);


                    User newUser = new User()
                    {
                        ID           = Guid.NewGuid(),
                        Username     = tbUsername.Text,
                        Password     = hashedPassword,
                        Salt         = salt,
                        FirstName    = tbFistName.Text,
                        LastName     = tbLastName.Text,
                        EmailAddress = tbEmail.Text
                    };
                    dc.Users.InsertOnSubmit(newUser);
                    dc.SubmitChanges();

                    HttpRuntime.Cache["UserID"] = newUser.ID;

                    signup.Visible   = false;
                    complete.Visible = true;

                    SendNewUserEmail(newUser.Username, newUser.EmailAddress);
                }
            }
            else
            {
                LoginError.InnerText = "PASSWORDS DO NOT MATCH. TRY HARDER.";
                LoginError.Visible   = true;
            }
        }