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

Pass Carto::User instead of User #15848

Merged
merged 2 commits into from
Sep 21, 2020
Merged

Pass Carto::User instead of User #15848

merged 2 commits into from
Sep 21, 2020

Conversation

@@ -84,6 +84,7 @@ class Carto::User < ActiveRecord::Base
alias_method :assets_dataset, :assets
alias_method :data_imports_dataset, :data_imports
alias_method :geocodings_dataset, :geocodings
def carto_user; self end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to be able to safely call both ::User#carto_user and ::Carto::User#carto_user. It will always return the ::Carto::User kind of object.

@@ -21,7 +21,7 @@ def access_token_with_xauth
if params[:x_auth_mode] == 'client_auth'
if user = authenticate(params[:x_auth_username], params[:x_auth_password])
@token = user.tokens.find_by(client_application: current_client_application, invalidated_at: nil)
@token = Carto::AccessToken.create(:user => user, :client_application => current_client_application) if @token.blank?
@token = Carto::AccessToken.create(user: user.carto_user, client_application_id: current_client_application.id) if @token.blank?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just a question about conventions: is it better to use keyword parameters instead of arrows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's not a such strong convention in Ruby as it can happen with Python PEP, but in all the projects I've worked on the tendency has been to use { a: 123 } instead of { :a => 123 }.

One of the "most used" style guidelines are the Rubocop standards, and it indicates to use this syntax: https://github.com/rubocop-hq/ruby-style-guide#hash-literals I (personally) prefer it since it's less verbose 😄 .

Copy link
Contributor

@manmorjim manmorjim Sep 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! thanks for the answer and the link 😄

@manmorjim
Copy link
Contributor

LGTM 👀 ✔️

@amiedes amiedes merged commit 958abaf into master Sep 21, 2020
@rafatower rafatower deleted the amiedes-token-hotfix-1 branch September 21, 2020 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants