Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gem push signs out logged in user #1724

Closed
sonalkr132 opened this issue May 14, 2018 · 2 comments · Fixed by #1739
Closed

gem push signs out logged in user #1724

sonalkr132 opened this issue May 14, 2018 · 2 comments · Fixed by #1739
Labels

Comments

@sonalkr132
Copy link
Member

Sign in to rubygems.org, push a gem using gem push <some.gem>. Reload rubygems.org in browser, user has been logged out.

@sonalkr132 sonalkr132 added the bug label May 14, 2018
@ecnelises
Copy link
Member

Actually cause of this bug is not related to gem push. If I logged in in one browser and log in again in another browser using the same username & passwords, the login session in the first browser will be reset. Because identification of current_user is implemented using User#remember_token, which is a field in users table. If a 'new me' logged in, the older remember token will be replaced by the newer one. That is to say any user can only logged in at one place.

@sonalkr132
Copy link
Member Author

We don't really have to support login from multiple sessions, it will be lot of work.
I find log out on gem push particularly annoying, and want to fix just that. authenticate_with_api_key gets called on every api request which needs authentication.

 def authenticate_with_api_key
    api_key = request.headers["Authorization"] || params[:api_key]
    sign_in User.find_by_api_key(api_key)
  end

It is signing in user on every api request. I can't think of any good reason to create a session on api call when we are sending api_key with all requests anyway. We can create an @api_user instead of sign_in and use it instead of current_user in api controllers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants