Skip to content

Commit

Permalink
Allow e-mail regex to be configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
GUI committed Sep 14, 2018
1 parent 56ea86a commit 15f14f3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ web:
min_threads: 2
max_threads: 24
api_user:
email_regex: "\\A[^@\\s]+@[^@\\s]+\\.[^@\\s]+\\z"
first_name_exclude_regex: "(http|https|www|<|>|\\r|\\n)"
last_name_exclude_regex: "(http|https|www|<|>|\\r|\\n)"
admin:
initial_superusers: []
username_is_email: true
password_length_min: 14
password_length_max: 72
email_regex: "\\A[^@\\s]+@[^@\\s]+\\z"
email_regex: "\\A[^@\\s]+@[^@\\s]+\\.[^@\\s]+\\z"
password_regex:
auth_strategies:
enabled:
Expand Down
2 changes: 1 addition & 1 deletion src/api-umbrella/web-app/app/models/api_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ApiUser
validates :email,
:presence => { :message => "Provide your email address." },
:format => {
:with => /.+@.+\..+/,
:with => proc { ::Regexp.new(ApiUmbrellaConfig[:web][:api_user][:email_regex], ::Regexp::IGNORECASE) },
:allow_blank => true,
:message => "Provide a valid email address.",
},
Expand Down
2 changes: 1 addition & 1 deletion src/api-umbrella/web-app/config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
# Email regex used to validate email formats. It simply asserts that
# one (and only one) @ exists in the given string. This is mainly
# to give user feedback and not to assert the e-mail validity.
config.email_regexp = Regexp.new(ApiUmbrellaConfig[:web][:admin][:email_regex])
config.email_regexp = ::Regexp.new(ApiUmbrellaConfig[:web][:admin][:email_regex], ::Regexp::IGNORECASE)

# ==> Configuration for :timeoutable
# The time you want to timeout the user session without activity. After this
Expand Down

0 comments on commit 15f14f3

Please sign in to comment.