From 0a561389a11315c5da982a86de7d0d215dcc69b2 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 20 2015 11:22:26 +0000 Subject: If request access the update endpoint using GET, redirects them to the issue If the user's session times-out and the user tries to add a comment to an issue, they will be redirected to the login page which in turn will redirect them to the update endpoint which can only work with POST queries. So quickly redirect the user to the issue page without doing anything else. --- diff --git a/progit/ui/issues.py b/progit/ui/issues.py index f7de32d..6a61a88 100644 --- a/progit/ui/issues.py +++ b/progit/ui/issues.py @@ -30,13 +30,19 @@ from progit import (APP, SESSION, LOG, __get_file_in_tree, cla_required, # URLs -@APP.route('//issue//update', methods=('GET', 'POST')) +@APP.route('//issue//update', methods=['GET', 'POST']) @APP.route('/fork///issue//update', - methods=('GET', 'POST')) + methods=['GET', 'POST']) +@cla_required def update_issue(repo, issueid, username=None): ''' Add a comment to an issue. ''' repo = progit.lib.get_project(SESSION, repo, user=username) + if flask.request.method == 'GET': + flask.flash('Invalid method: GET', 'error') + return flask.redirect(flask.url_for( + 'view_issue', username=username, repo=repo.name, issueid=issueid)) + if repo is None: flask.abort(404, 'Project not found')