コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String ls_UID = Request.QueryString["mail_confirm"];

            if (ls_UID != null)
            {
                cl_UserContext UserContext = new cl_UserContext("users_base");
                cl_User        User        = new cl_User();
                foreach (cl_User temp in UserContext.db_Users)
                {
                    if (temp.GUID.ToString() == ls_UID && temp.Attribute == "email_confirm")
                    {
                        temp.Attribute = "null";
                        UserContext.SaveChanges();
                        Response.Redirect("authorization.aspx");
                    }
                }
            }
        }
コード例 #2
0
        protected void Button_SignIn_Click(object sender, EventArgs e)
        {
            cl_UserContext UserContext = new cl_UserContext("users_base");
            cl_User        User        = new cl_User();

            User.Login    = TextBox_Login.Text.ToLower();
            User.Password = lcl_Cr.ps_MD5(TextBox_Pass.Text);

            Boolean lb_SignIn = false;

            foreach (cl_User temp in UserContext.db_Users)
            {
                if (temp.Login == User.Login & temp.Password == User.Password)
                {
                    lb_SignIn = true;
                    cl_Data.str_UserData l_UserData = new cl_Data.str_UserData()
                    {
                        Name       = temp.Name,
                        Surname    = temp.Surname,
                        Login      = temp.Login,
                        GUID       = temp.GUID,
                        Email      = temp.Email,
                        Permission = temp.Permission
                    };
                    Session.Add("user_data", l_UserData);
                    if (cb_RememberSignIn.Checked == true)
                    {
                        HttpCookie Cookie = new HttpCookie("cookie_User_Data");
                        Cookie.Expires      = DateTime.Now.AddYears(100);
                        Cookie["user_data"] = l_UserData.GUID.ToString();
                        Response.Cookies.Add(Cookie);
                    }
                    Response.Redirect("default.aspx");
                }
            }

            if (lb_SignIn == false)
            {
                Label_SignIn.Text = "НЕВЕРНЫЙ ЛОГИН ИЛИ ПАРОЛЬ";
            }
        }
コード例 #3
0
        protected void Button_SignUp_Click(object sender, EventArgs e)
        {
            Label_SignUp.Text = "";
            Boolean b_CheckEmpty = false;

            List <TextBox> list_TB = new List <TextBox>();

            list_TB.Add(TextBox_Name);
            list_TB.Add(TextBox_Surname);
            list_TB.Add(TextBox_Login);
            list_TB.Add(TextBox_Email);
            list_TB.Add(TextBox_Pass);

            foreach (TextBox temp in list_TB)
            {
                if (String.IsNullOrWhiteSpace(temp.Text) == false)
                {
                    b_CheckEmpty = true;
                }
                else
                {
                    b_CheckEmpty   = false;
                    temp.BackColor = System.Drawing.Color.DarkRed;
                }
            }

            if (b_CheckEmpty == false)
            {
                Label_SignUp.Text = "ЗАПОЛНИТЕ ВСЕ ПОЛЯ РЕГИСТРАЦИИ";
            }

            if (b_CheckEmpty == true)
            {
                cl_UserContext UserContext = new cl_UserContext("users_base");
                cl_User        User        = new cl_User();
                User.Login = TextBox_Login.Text.ToLower();
                User.Email = TextBox_Email.Text.ToLower();

                bool b_Login = false;
                bool b_Email = false;
                foreach (cl_User temp in UserContext.db_Users)
                {
                    if (temp.Login == User.Login)
                    {
                        b_Login           = true;
                        Label_SignUp.Text = "ПОЛЬЗОВАТЕЛЬ С ТАКИМ ЛОГИНОМ СУЩЕСТВУЕТ";
                    }
                    if (temp.Email == User.Email)
                    {
                        b_Email           = true;
                        Label_SignUp.Text = "ПОЛЬЗОВАТЕЛЬ С ТАКИМ EMAIL СУЩЕСТВУЕТ";
                    }
                }
                if (b_Login == false && b_Email == false)
                {
                    User.Name    = TextBox_Name.Text;
                    User.Surname = TextBox_Surname.Text;
                    cl_Cryptography lcl_Cr = new cl_Cryptography();
                    User.Password   = lcl_Cr.ps_MD5(TextBox_Pass.Text);
                    User.GUID       = Guid.NewGuid();
                    User.Permission = "user";
                    User.Attribute  = "email_confirm";
                    User.Blocked    = false;
                    User.RegDate    = DateTime.Now.ToLongDateString();
                    UserContext.db_Users.Add(User);
                    UserContext.SaveChanges();
                    Label_SignUp.Text = "ДЛЯ ЗАВЕРШЕНИЯ РЕГИСТРАЦИИ ПОДТВЕРДИТЕ УКАЗАННЫЙ ВАМИ EMAIL";
                    cl_Mail l_Mail = new cl_Mail();
                    l_Mail.pv_Mail_ConfirmRegistration(User.GUID.ToString(), User.Email, User.Name, User.Surname);
                }
            }
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string pageName = Path.GetFileNameWithoutExtension(Page.AppRelativeVirtualPath);

            if (pageName.ToLower() != "default")
            {
                ASPxImageSlider2.Visible = false;
            }

            LinkButton_SignOut.Visible = false;
            if (File.Exists(Server.MapPath("App_Data\\users_base.sdf")) == false)
            {
                cl_UserContext UserContext = new cl_UserContext("users_base");
                cl_User        User        = new cl_User
                {
                    Login      = "******".ToLower(),
                    Password   = lcl_Cr.ps_MD5("unlibro348"),
                    Name       = "Артур",
                    Surname    = "Хусаинов",
                    Blocked    = false,
                    GUID       = Guid.NewGuid(),
                    Attribute  = "null",
                    Email      = "*****@*****.**".ToLower(),
                    Permission = "administrator",
                    RegDate    = DateTime.Now.ToLongDateString()
                };
                UserContext.db_Users.Add(User);
                UserContext.SaveChanges();
            }
            Boolean lb_UserData = false;

            if (Session["user_data"] != null)
            {
                lb_UserData = true;
            }

            if (lb_UserData == false)
            {
                HttpCookie co_Cookie = Request.Cookies["cookie_User_Data"];
                if (co_Cookie != null && String.IsNullOrEmpty(co_Cookie["user_data"]) == false)
                {
                    cl_UserContext UserContext = new cl_UserContext("users_base");
                    cl_User        User        = new cl_User();
                    foreach (cl_User temp in UserContext.db_Users)
                    {
                        if (temp.GUID.ToString() == co_Cookie["user_data"])
                        {
                            cl_Data.str_UserData l_UserData = new cl_Data.str_UserData()
                            {
                                Name       = temp.Name,
                                Surname    = temp.Surname,
                                Login      = temp.Login,
                                GUID       = temp.GUID,
                                Email      = temp.Email,
                                Permission = temp.Permission
                            };
                            Session["user_data"] = l_UserData;
                        }
                    }
                    lb_UserData = true;
                }
            }

            if (lb_UserData == true)
            {
                LinkButton_SignIn.Visible  = false;
                LinkButton_SignOut.Visible = true;
                Label1.Text = "ПОЛЬЗОВАТЕЛЬ: ";
                cl_Data.str_UserData l_UserData = (cl_Data.str_UserData)Session["user_data"];
                LinkButton_User.Text = l_UserData.Surname + " " + l_UserData.Name;
            }

            else
            {
                Label1.Text          = "";
                LinkButton_User.Text = "";
            }
        }