diff --git a/pagure/api/issue.py b/pagure/api/issue.py index ff4d26a..8738a59 100644 --- a/pagure/api/issue.py +++ b/pagure/api/issue.py @@ -78,6 +78,11 @@ def api_new_issue(repo, username=None): if repo != flask.g.token.project: raise pagure.exceptions.APIError(401, error_code=APIERROR.EINVALIDTOK) + user_obj = pagure.lib.__get_user( + SESSION, flask.g.fas_user.username) + if not user_obj: + raise pagure.exceptions.APIError(404, error_code=APIERROR.ENOUSER) + form = pagure.forms.IssueFormSimplied(csrf_enabled=False) if form.validate_on_submit(): title = form.title.data @@ -102,7 +107,7 @@ def api_new_issue(repo, username=None): repo=repo, issue=issue, ticketfolder=APP.config['TICKETS_FOLDER'], - user=flask.g.fas_user, + user=user_obj, filename=filestream.filename, filestream=filestream.stream, ) diff --git a/pagure/lib/git.py b/pagure/lib/git.py index cc6ab17..524b1c3 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -679,7 +679,7 @@ def add_file_to_git(repo, issue, ticketfolder, user, filename, filestream): # Author/commiter will always be this one author = pygit2.Signature( name=user.username.encode('utf-8'), - email=user.email.encode('utf-8') + email=user.default_email.encode('utf-8') ) # Actually commit diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py index 2b07857..b954aac 100644 --- a/pagure/ui/issues.py +++ b/pagure/ui/issues.py @@ -576,6 +576,13 @@ def new_issue(repo, username=None): content = form.issue_content.data private = form.private.data + user_obj = pagure.lib.__get_user( + SESSION, flask.g.fas_user.username) + if not user_obj: + flask.abort( + 404, 'No such user found in the database: %s' % + flask.g.fas_user.username) + try: issue = pagure.lib.new_issue( SESSION, @@ -594,7 +601,7 @@ def new_issue(repo, username=None): repo=repo, issue=issue, ticketfolder=APP.config['TICKETS_FOLDER'], - user=flask.g.fas_user, + user=user_obj, filename=filestream.filename, filestream=filestream.stream, ) @@ -788,6 +795,13 @@ def edit_issue(repo, issueid, username=None): status = form.status.data private = form.private.data + user_obj = pagure.lib.__get_user( + SESSION, flask.g.fas_user.username) + if not user_obj: + flask.abort( + 404, 'No such user found in the database: %s' % + flask.g.fas_user.username) + try: message = pagure.lib.edit_issue( SESSION, @@ -808,7 +822,7 @@ def edit_issue(repo, issueid, username=None): repo=repo, issue=issue, ticketfolder=APP.config['TICKETS_FOLDER'], - user=flask.g.fas_user, + user=user_obj, filename=filestream.filename, filestream=filestream.stream, ) @@ -875,6 +889,13 @@ def upload_issue(repo, issueid, username=None): if issue is None or issue.project != repo: flask.abort(404, 'Issue not found') + user_obj = pagure.lib.__get_user( + SESSION, flask.g.fas_user.username) + if not user_obj: + flask.abort( + 404, 'No such user found in the database: %s' % + flask.g.fas_user.username) + form = pagure.forms.UploadFileForm() # pylint: disable=E1101 if form.validate_on_submit(): @@ -883,7 +904,7 @@ def upload_issue(repo, issueid, username=None): repo=repo, issue=issue, ticketfolder=APP.config['TICKETS_FOLDER'], - user=flask.g.fas_user, + user=user_obj, filename=filestream.filename, filestream=filestream.stream, )