diff --git a/lib/devise/twitter.rb b/lib/devise/twitter.rb index 199d1c4..3746dce 100644 --- a/lib/devise/twitter.rb +++ b/lib/devise/twitter.rb @@ -12,6 +12,16 @@ module Twitter mattr_accessor :scope @@scope = nil + + mattr_accessor :twitter_handle_field + @@twitter_handle_field = "twitter_handle" + + mattr_accessor :twitter_oauth_token_field + @@twitter_oauth_token_field = "twitter_oauth_token" + + mattr_accessor :twitter_oauth_secret_field + @@twitter_oauth_secret_field = "twitter_oauth_secret" + # Default way to setup Devise. Run rails generate devise_install to create # a fresh initializer with all configuration values. def self.setup diff --git a/lib/devise/twitter/version.rb b/lib/devise/twitter/version.rb index f9e81ba..4bbe623 100644 --- a/lib/devise/twitter/version.rb +++ b/lib/devise/twitter/version.rb @@ -1,5 +1,5 @@ module Devise module Twitter - VERSION = "0.1.2.pre" + VERSION = "0.1.2" end end diff --git a/lib/devise/twitter/warden.rb b/lib/devise/twitter/warden.rb index 726b4b9..ebc449f 100644 --- a/lib/devise/twitter/warden.rb +++ b/lib/devise/twitter/warden.rb @@ -5,13 +5,13 @@ if perform_connect # Add twitter_handle to current user - already_existing_user = klass.first(:twitter_handle => twitter_handle) + already_existing_user = klass.first(Devise::Twitter.twitter_handle_field => twitter_handle) if already_existing_user.blank? # We don't know anyone with this handle, therefore continue with connecting user = @env['warden'].user - user.login = twitter_handle - user.token = access_token.token - user.secret = access_token.secret + user.send("#{Devise::Twitter.twitter_handle_field}=",twitter_handle) + user.send("#{Devise::Twitter.twitter_oauth_token_field}=", access_token.token) + user.send("#{Devise::Twitter.twitter_oauth_secret_field}=", access_token.secret) user.save return user else @@ -23,7 +23,7 @@ previous_user = @env['warden'].user # Try to find user by token - user = klass.first(:token=> access_token.token, :secret => access_token.secret) + user = klass.first(:Devise::Twitter.twitter_oauth_token_field=> access_token.token, Devise::Twitter.twitter_oauth_secret_field => access_token.secret) # Since we are logging in a new user we want to make sure the before_logout hook is called @env['warden'].logout if previous_user.present? @@ -31,9 +31,9 @@ if user.nil? # Create user if we don't know him yet user = klass.new - user.login = twitter_handle - user.token = access_token.token - user.secret = access_token.secret + user.send("#{Devise::Twitter.twitter_handle}=",twitter_handle) + user.send("#{Devise::Twitter.twitter_oauth_token}=", access_token.token) + user.send("#{Devise::Twitter.twitter_oauth_secret}=", access_token.secret) user.save end