Permalink
Browse files

add default_email_suffix for when full email address is not given

  • Loading branch information...
1 parent ce557aa commit 5df15d11a251e0b93c94daa6a5e72f56b573a92f @joshk committed Mar 26, 2010
Showing with 7 additions and 0 deletions.
  1. +4 −0 lib/devise_imapable.rb
  2. +3 −0 lib/devise_imapable/model.rb
View
@@ -9,6 +9,10 @@ module Devise
# imap server address for authentication.
mattr_accessor :imap_server
@@imap_server = nil
+
+ # default email suffix
+ mattr_accessor :default_email_suffix
+ @@imap_server = nil
end
# Add +:imapable+ strategy to defaults.
@@ -62,6 +62,9 @@ def authenticate_with_imap(attributes={})
# end
#
def find_or_initialize_for_authentication(conditions)
+ unless conditions[:email] && conditions[:email].include?('@')
+ conditions[:email] = "#{conditions[:email]}@#{Devise.default_email_suffix}"
+ end
find(:first, :conditions => conditions) || new(conditions)
end
end

0 comments on commit 5df15d1

Please sign in to comment.