Exemplo n.º 1
0
        protected AppUser ValidateLogin(string username, string passwd)
        {
            List <String>  list   = GetSystemDriverList();
            DBManager      db     = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC);
            OdbcDataReader reader = null;

            try
            {
                reader = db.Query("SELECT u.*, b.branch_name as branch_name FROM user u, branch b  WHERE u.username='******' AND u.branch_id=b.branch_id");
                while (reader.Read())
                {
                    AppUser user = AppUser.CreateForm(reader);
                    if (user._encodedPassword == null)
                    {
                        return(null);
                    }
                    if (user._encodedPassword.Equals(AppUser.GetMD5Encoded(passwd)))
                    {
                        return(user);
                    }
                }
                return(null);
            }
            catch (Exception e) { Console.WriteLine(e.StackTrace); return(null); }
            finally { db.Close(reader); }
        }