DIYgod/RSSHub · critical · Error

新闻网登录失败

Error message

新闻网登录失败

What it means

The GDUT news site required a form-based login (hardcoded credentials gdutnews/newsgdut) before listing pages were accessible. The login POST returns a 302 redirect; if the Location header still contains 'UserLogin', the credentials were rejected and the route throws '新闻网登录失败' (news site login failed). Note: the entire module is commented out because news.gdut.edu.cn no longer exists — this error can only fire on a dead/deprecated code path.

Source

Thrown at lib/routes/gdut/news.ts:50

    const $ = load(loginResp.data);
    $('input[type=hidden]').each((index, element) => {
        postdata[$(element).attr('name')] = $(element).attr('value');
    });

    // 登录
    await got({
        method: 'post',
        url: site + login,
        headers: {
            Cookie: cookie,
            Referer: site + login,
        },
        form: postdata,
    }).catch((e) => {
        if (e.statusCode === 302) {
            if (/UserLogin/.test(e.headers.location)) {
                throw new Error('新闻网登录失败');
            }
        } else {
            throw e;
        }
    });
    return cookie;
}

export default async (ctx) => {
    const page = '/ArticleList.aspx?category=4';

    // 缓存cookie
    let cookie = await cache.get(site + page);
    if (!cookie) {
        cookie = await getCookie();
        cache.set(site + page, cookie);
    }

View on GitHub (pinned to bed535e087)

Solutions

  1. Since the source site (news.gdut.edu.cn) no longer exists and the module is commented out, remove the route entirely rather than fix credentials.
  2. If reviving, fetch fresh hidden fields and update credentials, or switch to a public endpoint that does not require login.
  3. Verify the 302 Location to distinguish credential failure from a WAF challenge (waf_verify).

Example fix

// before
}).catch((e) => {
    if (e.statusCode === 302) {
        if (/UserLogin/.test(e.headers.location)) {
            throw new Error('新闻网登录失败');
        }
    } else {
        throw e;
    }
});

// after
// The news.gdut.edu.cn site is decommissioned. Remove this route.
// If a replacement public feed exists, switch to it and drop the login flow.
Defensive patterns

Strategy: try-catch

Prevention

When it happens

Trigger: The hardcoded credentials were changed on the server, the ASP.NET hidden-field validation (viewstate/eventvalidation) failed so the POST was rejected, or the login endpoint changed. The 302 back to UserLogin is the server's 'login failed' signal.

Common situations: Hardcoded shared credentials being rotated by the university; ASP.NET viewstate tampering; the site being replaced (as it has been — the file is fully commented out). This error is effectively unreachable in the current repository.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/854e212eece9fdcf. Report an issue: GitHub.