0
@@ -32,21 +32,26 @@ class User < ActiveRecord::Base
0
# Virtual attribute for the unencrypted password
0
attr_accessor :password
0
+ attr_accessor :skip_email
0
# basic info validations
0
- validates_presence_of :ip_address, :unless => :signed_up?
0
- validates_presence_of :login, :if => :signed_up?
0
- validates_presence_of :email, :if => :signed_up?
0
- validates_length_of :login, :within => 3..40, :if => :signed_up?
0
- validates_length_of :email, :within => 3..100, :if => :signed_up?
0
- validates_uniqueness_of :login, :email, :case_sensitive => false, :if => :signed_up?
0
- validates_as_email_address :email, :if => :signed_up?
0
+ validates_presence_of :login, :if => :signed_up?
0
+ validates_length_of :login, :within => 3..40, :if => :signed_up?, :allow_blank => true
0
+ validates_uniqueness_of :login, :case_sensitive => false, :if => :signed_up?, :allow_blank => true
0
+ validates_format_of :login, :with => /^\w+$/i, :message => "must only contain letters and numbers", :allow_blank => true
0
+ validates_presence_of :email, :if => :email_required?
0
+ validates_length_of :email, :within => 3..100, :if => :email_required?
0
+ validates_uniqueness_of :email, :case_sensitive => false, :if => :email_required?
0
+ validates_as_email_address :email, :if => :email_required?
0
- validates_presence_of :password, :if => :password_required?
0
- validates_presence_of :password_confirmation, :if => :password_required?
0
- validates_length_of :password, :within => 4..40, :if => :password_required?
0
- validates_confirmation_of :password, :if => :password_required?
0
+ validates_presence_of :password, :if => :password_required?
0
+ validates_presence_of :password_confirmation, :if => :password_required?
0
+ validates_length_of :password, :within => 4..40, :if => :password_required?
0
+ validates_confirmation_of :password, :if => :password_required?
0
before_save :encrypt_password
0
# prevents a user from submitting a crafted form that bypasses activation
0
@@ -184,8 +189,8 @@ class User < ActiveRecord::Base
0
+ return self.login unless self[:login].blank?
0
return self.name unless self.name.blank?
0
- return self.login unless self.login.blank?
0
@@ -268,6 +273,18 @@ class User < ActiveRecord::Base
0
self.activities.each{|r| r.destroy}
0
+ !self.identity_url.blank?
0
+ self.open_id? and self.login.include?("user_")
0
+ signed_up? and !open_id?
0
User.find(:all, :conditions => {:spammer => true}).each do |user|
0
@@ -296,7 +313,7 @@ class User < ActiveRecord::Base
0
logger.debug("REGISTERING!")
0
- if AppConfig.require_email_activation
0
+ if AppConfig.require_email_activation
and !self.skip_email0
@@ -313,7 +330,7 @@ class User < ActiveRecord::Base
0
self.activated_at = Time.now.utc
0
self.deleted_at = self.activation_code = nil
0
- if AppConfig.require_email_activation
0
+ if AppConfig.require_email_activation
and !self.skip_email0
UserMailer.deliver_activation_success(self)
0
UserMailer.deliver_signup_notification(self)
Comments
No one has commented yet.