Creating notifier and first attempt to send instructions to confirm by email. Some minor refactoring.

This commit is contained in:
Carlos A. da Silva
2009-09-17 19:54:19 -03:00
parent bb336150fe
commit 3e6d1ffe43
8 changed files with 82 additions and 5 deletions

View File

@@ -1,3 +1,5 @@
require 'devise/authenticable'
require 'devise/confirmable'
require 'devise/notifier'

View File

@@ -6,6 +6,7 @@ module Devise
extend ClassMethods
before_create :generate_confirmation_token
after_create :send_confirmation_instructions
end
end
@@ -35,8 +36,21 @@ module Devise
self.confirmation_token = secure_digest(Time.now.utc, random_string, password)
end
# Send confirmation instructions by email
def send_confirmation_instructions
# ::Devise::Notifier.deliver_confirmation_instructions(self)
end
module ClassMethods
# Hook default authenticate to provide test whether the account is confirmed
# Returns the authenticated_user if it's confirmed, otherwise returns nil
# TODO
#def authenticate(email, password)
# confirmable = super
# confirmable if confirmable.confirmed? unless confirmable.nil?
#end
# Find a user by it's confirmation token and try to confirm it.
# If no user is found, returns a new user
# If the user is already confirmed, create an error for the user

10
lib/devise/notifier.rb Normal file
View File

@@ -0,0 +1,10 @@
module Devise
class Notifier < ::ActionMailer::Base
self.view_paths.unshift(File.join(File.dirname(__FILE__), '..', '..', 'views'))
def confirmation_instructions(record)
#
end
end
end