Пример #1
0
        protected void SignUp_Click(object sender, EventArgs e)
        {
            User_Class newUser = new User_Class();

            newUser.Name = Name.Text;
            newUser.Surname = Surname.Text;
            newUser.Pass = Password.Text;
            newUser.Nick = UserName.Text;
            newUser.Email = Email.Text;

            foreach (ListItem li in ListBox1.Items)
            {
                if (li.Selected == true)
                {
                    if (Int32.Parse(li.Value) == 0)
                    {
                        newUser.Gender = 'F';
                    }
                    else if (Int32.Parse(li.Value) == 1)
                    {
                        newUser.Gender = 'M';
                    }

                }
            }

            newUser.Entry_date = DateTime.Now.ToShortDateString();
            newUser.Birth_date = Calendar1.SelectedDate.ToString();
            newUser.Image_url = "../Images/no_image.jpeg";

            if (!newUser.existeUsuario(newUser.Nick))
            {
                newUser.addUser();
                string subject = "[Thanks for signing up Sticky Notes]";
                MailMessage mail = new MailMessage();
                mail.To.Add(Email.Text);
                mail.From = new MailAddress("*****@*****.**");
                mail.Subject = subject;
                mail.Body = "Thanks by have been registered in Sticky Notes.\n\nYour User information is:\nUser: "******"\nPass: "******"\n\nI hope you enjoy our social network.\nSticky Notes’ team.";
                mail.IsBodyHtml = false;
                mail.Priority = MailPriority.Normal;
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
                smtp.EnableSsl = true;
                smtp.Credentials = new NetworkCredential("*****@*****.**", "projecthada");
                smtp.Send(mail);

                Response.Redirect("..//Account/Login.aspx");
            }
            else
            {
                SameUserfailure.Text = "This UserName already exists.";
            }
        }
Пример #2
0
        protected void Login_Master(object sender, EventArgs e)
        {
            HttpCookie userCookie;
            HttpCookie passCookie;
            userCookie = Request.Cookies["UserID"];
            passCookie = Request.Cookies["UserPass"];
            if (userCookie != null)
            {
                userCookie.Expires = DateTime.Now.AddMonths(-1);
                Response.Cookies.Add(userCookie);
            }
            if (passCookie != null)
            {
                passCookie.Expires = DateTime.Now.AddMonths(-1);
                Response.Cookies.Add(passCookie);
            }

            User_Class myUser = new User_Class();
            User_Class myUser2 = new User_Class();

            myUser.Nick = UserName.Text;
            myUser.Pass = Password.Text;
            object refUrl = ViewState["RefUrl"];
            if (myUser.existeUsuario(myUser.Nick))
            {
                myUser2 = myUser.getUser(myUser.Nick);
                if (myUser.Pass == myUser2.Pass)
                {

                    userCookie = new HttpCookie("UserID", myUser2.Nick);
                    passCookie = new HttpCookie("UserPass", myUser2.Pass);
                    userCookie.Expires = DateTime.Now.AddMonths(1);
                    passCookie.Expires = DateTime.Now.AddMonths(1);
                    Response.Cookies.Add(userCookie);
                    Response.Cookies.Add(passCookie);
                    Label1.Text = "Welcome " + myUser.Nick;
                    UserLabel.Visible = false;
                    UserName.Visible = false;
                    PasswordLabel.Visible = false;
                    Password.Visible = false;
                    Button1.Visible = false;
                    Button3.Visible = false;
                    Button2.Visible = true;

                    if (HttpContext.Current.Request.Url.LocalPath == "/default.aspx" || HttpContext.Current.Request.Url.LocalPath == "/Default.aspx" || HttpContext.Current.Request.Url.LocalPath == "/About.aspx")
                    {
                        Response.Redirect("/Default.aspx");
                    }
                    else
                    {
                        Response.Redirect("../Default.aspx");
                    }
                }
                else
                {
                    Label1.Text = "Contraseña incorrecta";
                }

            }
            else
            {
                Label1.Text = "No existe el usuario";
            }
        }
Пример #3
0
        protected void Login_Click(object sender, EventArgs e)
        {
            HttpCookie userCookie;
            HttpCookie passCookie;

            userCookie = Request.Cookies["UserID"];
            passCookie = Request.Cookies["UserPass"];

            if (userCookie != null || passCookie != null)
            {
                if (userCookie != null)
                {
                    userCookie.Expires = DateTime.Now.AddMonths(-1);
                    Response.Cookies.Add(userCookie);
                }
                else
                {
                    passCookie.Expires = DateTime.Now.AddMonths(-1);
                    Response.Cookies.Add(passCookie);
                }
            }
            else
            {
                ViewState["RefUrl"] = "..//Default.aspx";
            }

            User_Class myUser = new User_Class();
            User_Class myUser2 = new User_Class();

            myUser.Nick = UserName.Text;
            myUser.Pass = Password.Text;
            object refUrl = ViewState["RefUrl"];

            if (myUser.existeUsuario(myUser.Nick))
            {
                myUser2 = myUser.getUser(myUser.Nick);
                if (myUser.Pass == myUser2.Pass)
                {

                    userCookie = new HttpCookie("UserID", myUser.Nick);
                    passCookie = new HttpCookie("UserPass", myUser.Pass);
                    userCookie.Expires = DateTime.Now.AddMonths(1);
                    passCookie.Expires = DateTime.Now.AddMonths(1);
                    Response.Cookies.Add(userCookie);
                    Response.Cookies.Add(passCookie);
                    if (refUrl != null)
                    {
                        Response.Redirect((string)refUrl);
                    }
                }
                else
                {
                    Label1.Text = "Contraseña incorrecta";
                }

            }
            else
            {
                Label1.Text = "No existe el usuario";
            }
        }