schneidmaster / gitreports.com

Git Reports is a free service that lets you set up a stable URL for anonymous users to submit bugs and other Issues to your GitHub repositories.
MIT License
134 stars 27 forks source link

create_issue url error: Collaborators aren't always the repository holder #49

Closed elor closed 9 years ago

elor commented 9 years ago

Hello,

When you're setting up a gitreport user who's only a collaborator, not the repository owner, before registering the actual owner, he'll be assumed to be the repository holder in this application. This can happen if you've set up a separate collaborator account for issue submission, as did I. During issue creation, the constructed url will then be constructed as collaborator/repo instead of owner/repo, since the owner is assumed to be self.users.first. collaborator/repo doesn't exist in the best case or is just the wrong repository in the worst. The first case leads to a 404 error when creating the issue, which in turn leads to a 500 server error in your application.

I can think of a few possible solutions, which might have unforeseen consequences

  1. app/controllers/authentications_controller.rb, line 94: prepend the repository owner to repo.users when adding the current user
  2. app/controllers/repositories_controller.rb, line 59`: use the full_path or owner key from the github api for the issue creation path instead of the first user who registered this repository
  3. app/models/repository.rb, line 33: return the actual owner instead of self.users.first
  4. add a holder or full_path key to the database and use it where necessary

Personally, I would prefer option 2, since that wouldn't require rewriting the current database and shouldn't interfere with the inner workings of the app.

I really like your application, but I'm not familiar with ruby, hence the issue instead of a pull request.

Best regards, Erik

schneidmaster commented 9 years ago

Thanks for the detailed error report- this is very helpful. I'll have a fix pushed out shortly.

schneidmaster commented 9 years ago

Fix is deployed. Please note that you will need to manually log out and log in for your repositories to be correctly updated.