예제 #1
0
파일: User.cs 프로젝트: AJereli/AllContent
        public static bool Registration(string login, string password, string email)
        {
            using (DBClient mysql_client = new DBClient())
            {
                string query = @"SELECT login FROM users WHERE login = @login;";

                if (mysql_client.SelectQuery(query, new MySqlParameter("login", login.ToLower())).Count > 0)
                {
                    return(false);
                }
                else
                {
                    MySqlParameters mysql_params = new MySqlParameters();

                    mysql_params.AddParameter(new MySqlParameter("login", login.ToLower()));
                    mysql_params.AddParameter(new MySqlParameter("password", MD5Hashing.GetMd5Hash(password)));
                    mysql_params.AddParameter(new MySqlParameter("email", email));
                    mysql_client.Query("INSERT INTO users (login, password, email) VALUES (@login, @password, @email)", mysql_params);
                    return(true);
                }
            }
        }
예제 #2
0
파일: User.cs 프로젝트: AJereli/AllContent
        public bool Authorization(string login, string password)
        {
            using (DBClient mysql_client = new DBClient())
            {
                string        query       = "SELECT password FROM users WHERE login = @login;";
                List <string> hashed_pass = mysql_client.SelectQuery(query, new MySqlParameter("login", login.ToLower()));
                if (hashed_pass.Count == 0)
                {
                    return(false);
                }

                if (MD5Hashing.CompareHashes(password, hashed_pass[0]))
                {
                    Name = login.ToLower();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }