Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ test/version_tmp
tmp
*.swp
example/app.log

.ruby-gemset

.ruby-version
32 changes: 24 additions & 8 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
Style/AlignParameters:
AllCops:
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
- 'tmp/**/*'
TargetRubyVersion: 2.2

Layout/AlignParameters:
# Alignment of parameters in multi-line method calls.
#
# The `with_first_parameter` style aligns the following lines along the same
Expand Down Expand Up @@ -32,8 +39,8 @@ Style/BracesAroundHashParameters:
- context_dependent

# Indentation of `when`.
Style/CaseIndentation:
IndentWhenRelativeTo: end
Layout/CaseIndentation:
EnforcedStyle: end
SupportedStyles:
- case
- end
Expand Down Expand Up @@ -77,11 +84,10 @@ Style/CommandLiteral:
Style/HashSyntax:
EnforcedStyle: hash_rockets
SupportedStyles:
- ruby19
- hash_rockets

# Checks the indentation of the first element in an array literal.
Style/IndentArray:
Layout/IndentArray:
# The value `special_inside_parentheses` means that array literals with
# brackets that have their opening bracket on the same line as a surrounding
# opening round parenthesis, shall have their first element indented relative
Expand All @@ -103,7 +109,7 @@ Style/IndentArray:
IndentationWidth: ~

# Checks the indentation of the first key in a hash literal.
Style/IndentHash:
Layout/IndentHash:
# The value `special_inside_parentheses` means that hash literals with braces
# that have their opening brace on the same line as a surrounding opening
# round parenthesis, shall have their first key indented relative to the
Expand All @@ -116,7 +122,7 @@ Style/IndentHash:
- special_inside_parentheses
- consistent

Style/MultilineMethodCallIndentation:
Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented
SupportedStyles:
- aligned
Expand All @@ -125,7 +131,7 @@ Style/MultilineMethodCallIndentation:
# But it can be overridden by setting this parameter
IndentationWidth: ~

Style/MultilineOperationIndentation:
Layout/MultilineOperationIndentation:
EnforcedStyle: indented
SupportedStyles:
- aligned
Expand Down Expand Up @@ -157,12 +163,22 @@ Metrics/MethodLength:
Metrics/LineLength:
Max: 120

Metrics/BlockLength:
CountComments: false
Exclude:
- 'Rakefile'
- '**/*.rake'
- 'spec/**/*.rb'

##################### Lint ################################

Lint/AssignmentInCondition:
Description: "Don't use assignment in conditions."
Enabled: false

Lint/ScriptPermission:
Enabled: false

##################### Performance #########################

# Performance improvement is negligible and the readability is poor. See:
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ rescue LoadError
end
end

task :default => [:spec, :rubocop]
task :default => %i[spec rubocop]
40 changes: 37 additions & 3 deletions lib/omniauth/strategies/dotloop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,46 @@ class Dotloop < OmniAuth::Strategies::OAuth2
# additional calls (if the user id is returned with the token
# or as a URI parameter). This may not be possible with all
# providers.
uid {}
uid { raw_info['data']['id'] }

# https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema#schema-10-and-later
info {}
info do
prune!(
:email => raw_info['data']['email'],
:first_name => raw_info['data']['first_name'],
:last_name => raw_info['data']['last_name']
)
end

extra {}
extra do
hash = {}
hash['raw_info'] = raw_info
prune! hash
end

def raw_info
@raw_info ||= access_token.get('https://api-gateway.dotloop.com/public/v2/account').parsed || {}
end

protected

def build_access_token
options.token_params[:headers] = { 'Authorization' => basic_auth_header }
super
end

def basic_auth_header
"Basic #{Base64.urlsafe_encode64("#{options[:client_id]}:#{options[:client_secret]}")}"
end

private

def prune!(hash)
hash.delete_if do |_, value|
prune!(value) if value.is_a?(Hash)
value.nil? || (value.respond_to?(:empty?) && value.empty?)
end
end
end
end
end
12 changes: 6 additions & 6 deletions omniauth-dotloop.gemspec
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
require File.expand_path('../lib/omniauth-dotloop/version', __FILE__)

Gem::Specification.new do |gem|
gem.authors = 'Contactually'
gem.email = 'api@contactually.com'
gem.description = 'OmniAuth OAuth2 strategy for Contactually.'
gem.authors = ['Contactually', 'Mwaki Harri Magotswi']
gem.email = ['api@contactually.com', 'magotswi@gmail.com']
gem.description = 'OmniAuth OAuth2 strategy for Dotloop.'
gem.summary = gem.description
gem.homepage = 'https://github.com/dotloop/omniauth-dotloop'
gem.licenses = %w(MIT)
gem.homepage = 'https://github.com/contactually/omniauth-dotloop'
gem.licenses = %w[MIT]

gem.executables = `git ls-files -- bin/*`.split("\n").collect { |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.name = 'omniauth-dotloop'
gem.require_paths = %w(lib)
gem.require_paths = %w[lib]
gem.version = OmniAuth::Dotloop::VERSION

# Lock at 1.3.x due to https://github.com/intridea/omniauth-oauth2/issues/81
Expand Down