4 require File.join(File.dirname(__FILE__), '..', '..', "lib", "authenticated_system", "authenticated_dependencies")
10 include DataMapper::Resource
11 include AuthenticatedSystem::Model
13 attr_accessor :password, :password_confirmation
15 property :id, Fixnum, :serial => true
16 property :login, String
17 property :email, String
18 property :crypted_password, String
19 property :salt, String
20 property :activation_code, String
21 property :activated_at, DateTime
22 property :remember_token_expires_at, DateTime
23 property :remember_token, String
24 property :created_at, DateTime
25 property :updated_at, DateTime
27 # FIXME: fix validations
28 #validates_length_of :login, :within => 3..40
29 #validates_uniqueness_of :login
30 #validates_presence_of :email
31 # validates_format_of :email, :as => :email_address
32 #validates_length_of :email, :within => 3..100
33 #validates_uniqueness_of :email
34 #validates_presence_of :password, :if => proc {password_required?}
35 #validates_presence_of :password_confirmation, :if => proc {password_required?}
36 #validates_length_of :password, :within => 4..40, :if => proc {password_required?}
37 #validates_confirmation_of :password, :groups => :create
39 # FIXME : fix callbacks
40 #before_save :encrypt_password
41 #before_create :make_activation_code
42 #after_create :send_signup_notification
45 @login = value.downcase unless value.nil?
49 EMAIL_FROM = "info@mysite.com"
50 SIGNUP_MAIL_SUBJECT = "Welcome to MYSITE. Please activate your account."
51 ACTIVATE_MAIL_SUBJECT = "Welcome to MYSITE"
53 # Activates the user in the database
56 self.activated_at = Time.now.utc
57 self.activation_code = nil
60 # send mail for activation
61 UserMailer.dispatch_and_deliver( :activation_notification,
62 { :from => User::EMAIL_FROM,
64 :subject => User::ACTIVATE_MAIL_SUBJECT },
70 def send_signup_notification
71 UserMailer.dispatch_and_deliver(
73 { :from => User::EMAIL_FROM,
75 :subject => User::SIGNUP_MAIL_SUBJECT },