Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow overriding of default validations of GenericUser.

  • Loading branch information...
commit b64af9689ea4a5c0d1695f5ef15131cdcb69fb64 1 parent 40cd689
Michael Bleigh authored
Showing with 14 additions and 7 deletions.
  1. +12 −6 app/models/twitter_auth/generic_user.rb
  2. +2 −1  lib/twitter_auth.rb
View
18 app/models/twitter_auth/generic_user.rb
@@ -24,12 +24,14 @@ class GenericUser < ActiveRecord::Base
:utc_offset
]
- validates_presence_of :login, :twitter_id
- validates_format_of :login, :with => /\A[a-z0-9_]+\z/i
- validates_length_of :login, :in => 1..15
- validates_uniqueness_of :login, :case_sensitive => false
- validates_uniqueness_of :twitter_id, :message => "ID has already been taken."
- validates_uniqueness_of :remember_token, :allow_blank => true
+ with_options :if => :utilize_default_validations do |v|
+ v.validates_presence_of :login, :twitter_id
+ v.validates_format_of :login, :with => /\A[a-z0-9_]+\z/i
+ v.validates_length_of :login, :in => 1..15
+ v.validates_uniqueness_of :login, :case_sensitive => false
+ v.validates_uniqueness_of :twitter_id, :message => "ID has already been taken."
+ v.validates_uniqueness_of :remember_token, :allow_blank => true
+ end
def self.table_name; 'users' end
@@ -70,6 +72,10 @@ def update_twitter_attributes(hash)
include TwitterAuth::BasicUser
end
+ def utilize_default_validations
+ true
+ end
+
def twitter
if TwitterAuth.oauth?
TwitterAuth::Dispatcher::Oauth.new(self)
View
3  lib/twitter_auth.rb
@@ -60,7 +60,8 @@ def self.consumer
[ :authorize_path,
:request_token_path,
:access_token_path,
- :scheme ].each do |oauth_option|
+ :scheme,
+ :signature_method ].each do |oauth_option|
options[oauth_option] = TwitterAuth.config[oauth_option.to_s] if TwitterAuth.config[oauth_option.to_s]
end
Please sign in to comment.
Something went wrong with that request. Please try again.