1
0
Fork 0
mirror of https://github.com/omniauth/omniauth.git synced 2022-11-09 12:31:49 -05:00

removed dist files -- no idea how those got in there

This commit is contained in:
James A. Rosen 2010-06-13 16:58:06 -04:00
parent e55fec40ee
commit 8e5b4516a8
2 changed files with 0 additions and 102 deletions

View file

@ -1,55 +0,0 @@
require 'omniauth/basic'
module OmniAuth
module Strategies
class Basecamp < HttpBasic
def initialize(app)
require 'json'
super(app, :basecamp, nil)
end
def endpoint
"http://#{request.params['user']}:#{request.params['password']}@#{request.params['subdomain']}.basecamphq.com/me.xml"
end
def perform_authentication(endpoint)
super(endpoint) rescue super(endpoint.sub('http','https'))
end
def auth_hash
doc = Nokogiri::XML.parse(@response.body)
OmniAuth::Utils.deep_merge(super, {
'uid' => doc.xpath('person/id').text,
'user_info' => user_info(doc),
'credentials' => {
'token' => doc.xpath('person/token').text
}
})
end
def user_info(doc)
hash = {
'nickname' => request.params['user'],
'first_name' => doc.xpath('person/first-name').text,
'last_name' => doc.xpath('person/last-name').text,
'email' => doc.xpath('person/email-address').text,
'image' => doc.xpath('person/avatar-url').text
}
hash['name'] = [hash['first_name'], hash['last_name']].join(' ').strip
hash.delete('image') if hash['image'].include?('missing/avatar.png')
hash
end
def get_credentials
OmniAuth::Form.build('Basecamp Authentication') do
text_field 'Subdomain', 'subdomain'
text_field 'Username', 'user'
password_field 'Password', 'password'
end.to_response
end
end
end
end

View file

@ -1,47 +0,0 @@
require 'omniauth/basic'
module OmniAuth
module Strategies
class Campfire < HttpBasic
def initialize(app)
require 'json'
super(app, :campfire, nil)
end
def endpoint
"http://#{request.params['user']}:#{request.params['password']}@#{request.params['subdomain']}.campfirenow.com/users/me.json"
end
def perform_authentication(endpoint)
super(endpoint) rescue super(endpoint.sub('http','https'))
end
def auth_hash
user_hash = JSON.parse(@response.body)['user']
OmniAuth::Utils.deep_merge(super, {
'uid' => user_hash['id'],
'user_info' => user_info(user_hash),
'credentials' => {
'token' => user_hash['api_auth_token']
}
})
end
def user_info(hash)
{
'nickname' => request.params['user'],
'name' => hash['name'],
'email' => hash['email_address']
}
end
def get_credentials
OmniAuth::Form.build('Campfire Authentication') do
text_field 'Subdomain', 'subdomain'
text_field 'Username', 'user'
password_field 'Password', 'password'
end.to_response
end
end
end
end