magneticow: allow no-auth also in feed url

This commit is contained in:
Martin Weinelt 2017-07-23 12:40:36 +02:00
parent 3a7de3daaf
commit 9a8d59c85e

View File

@ -118,8 +118,12 @@ def torrents():
else: else:
context["next_page_exists"] = True context["next_page_exists"] = True
if app.arguments.noauth:
context["subscription_url"] = "/feed/?filter%s" % search
else:
username, password = flask.request.authorization.username, flask.request.authorization.password username, password = flask.request.authorization.username, flask.request.authorization.password
context["subscription_url"] = "/feed?filter=%s&hash=%s" % (search, generate_feed_hash(username, password, search)) context["subscription_url"] = "/feed?filter=%s&hash=%s" % (
search, generate_feed_hash(username, password, search))
if sort_by: if sort_by:
context["sorted_by"] = sort_by context["sorted_by"] = sort_by
@ -210,9 +214,10 @@ def statistics():
@app.route("/feed") @app.route("/feed")
def feed(): def feed():
filter_ = flask.request.args["filter"] filter_ = flask.request.args["filter"]
hash_ = flask.request.args["hash"]
# Check for all possible users who might be requesting. # Check for all possible users who might be requesting.
# pylint disabled: because we do monkey-patch! [in magneticow.__main__.py:main()] # pylint disabled: because we do monkey-patch! [in magneticow.__main__.py:main()]
if not app.arguments.noauth:
hash_ = flask.request.args["hash"]
for username, password in app.arguments.user: # pylint: disable=maybe-no-member for username, password in app.arguments.user: # pylint: disable=maybe-no-member
if generate_feed_hash(username, password, filter_) == hash_: if generate_feed_hash(username, password, filter_) == hash_:
break break