-
Notifications
You must be signed in to change notification settings - Fork 653
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
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 |
There was a problem hiding this comment.
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? |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 😄 .
There was a problem hiding this comment.
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 😄
LGTM 👀 ✔️ |
Fixes https://rollbar.com/carto/CartoDB/items/42935/?utm_campaign=new_item_message&utm_medium=slack&utm_source=rollbar-notification