Skip to content

Commit

Permalink
Merge branch 'master' of github.com:binarylogic/authlogic
Browse files Browse the repository at this point in the history
  • Loading branch information
binarylogic committed Jun 1, 2012
2 parents fd433eb + ef7bb3d commit defdfeb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/authlogic/acts_as_authentic/email.rb
Expand Up @@ -65,7 +65,7 @@ def merge_validates_length_of_email_field_options(options = {})
# * <tt>Default:</tt> {:with => Authlogic::Regex.email, :message => lambda {I18n.t('error_messages.email_invalid', :default => "should look like an email address.")}}
# * <tt>Accepts:</tt> Hash of options accepted by validates_format_of
def validates_format_of_email_field_options(value = nil)
rw_config(:validates_format_of_email_field_options, value, {:with => Authlogic::Regex.email, :message => I18n.t('error_messages.email_invalid', :default => "should look like an email address.")})
rw_config(:validates_format_of_email_field_options, value, {:with => Authlogic::Regex.email, :message => lambda {I18n.t('error_messages.email_invalid', :default => "should look like an email address.")}})
end
alias_method :validates_format_of_email_field_options=, :validates_format_of_email_field_options

Expand Down Expand Up @@ -107,4 +107,4 @@ def self.included(klass)
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/authlogic/acts_as_authentic/login.rb
Expand Up @@ -62,7 +62,7 @@ def merge_validates_length_of_login_field_options(options = {})
# * <tt>Default:</tt> {:with => Authlogic::Regex.login, :message => lambda {I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}}
# * <tt>Accepts:</tt> Hash of options accepted by validates_format_of
def validates_format_of_login_field_options(value = nil)
rw_config(:validates_format_of_login_field_options, value, {:with => Authlogic::Regex.login, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")})
rw_config(:validates_format_of_login_field_options, value, {:with => Authlogic::Regex.login, :message => lambda {I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}})
end
alias_method :validates_format_of_login_field_options=, :validates_format_of_login_field_options

Expand Down
13 changes: 7 additions & 6 deletions lib/authlogic/regex.rb
Expand Up @@ -9,17 +9,18 @@ module Regex
# by reading this website: http://www.regular-expressions.info/email.html, which is an excellent resource
# for regular expressions.
def self.email
return @email_regex if @email_regex
email_name_regex = '[A-Z0-9_\.%\+\-\']+'
domain_head_regex = '(?:[A-Z0-9\-]+\.)+'
domain_tld_regex = '(?:[A-Z]{2,4}|museum|travel)'
@email_regex = /\A#{email_name_regex}@#{domain_head_regex}#{domain_tld_regex}\z/i
@email_regex ||= begin
email_name_regex = '[A-Z0-9_\.%\+\-\']+'
domain_head_regex = '(?:[A-Z0-9\-]+\.)+'
domain_tld_regex = '(?:[A-Z]{2,4}|museum|travel)'
/\A#{email_name_regex}@#{domain_head_regex}#{domain_tld_regex}\z/i
end
end

# A simple regular expression that only allows for letters, numbers, spaces, and .-_@. Just a standard login / username
# regular expression.
def self.login
/\A\w[\w\.+\-_@ ]+$/
/\A\w[\w\.+\-_@ ]+\z/
end
end
end

0 comments on commit defdfeb

Please sign in to comment.