Skip to content

Commit 15f14f3

Browse files
committed
Allow e-mail regex to be configurable.
1 parent 56ea86a commit 15f14f3

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

config/default.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,15 @@ web:
7979
min_threads: 2
8080
max_threads: 24
8181
api_user:
82+
email_regex: "\\A[^@\\s]+@[^@\\s]+\\.[^@\\s]+\\z"
8283
first_name_exclude_regex: "(http|https|www|<|>|\\r|\\n)"
8384
last_name_exclude_regex: "(http|https|www|<|>|\\r|\\n)"
8485
admin:
8586
initial_superusers: []
8687
username_is_email: true
8788
password_length_min: 14
8889
password_length_max: 72
89-
email_regex: "\\A[^@\\s]+@[^@\\s]+\\z"
90+
email_regex: "\\A[^@\\s]+@[^@\\s]+\\.[^@\\s]+\\z"
9091
password_regex:
9192
auth_strategies:
9293
enabled:

src/api-umbrella/web-app/app/models/api_user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ApiUser
5959
validates :email,
6060
:presence => { :message => "Provide your email address." },
6161
:format => {
62-
:with => /.+@.+\..+/,
62+
:with => proc { ::Regexp.new(ApiUmbrellaConfig[:web][:api_user][:email_regex], ::Regexp::IGNORECASE) },
6363
:allow_blank => true,
6464
:message => "Provide a valid email address.",
6565
},

src/api-umbrella/web-app/config/initializers/devise.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
# Email regex used to validate email formats. It simply asserts that
162162
# one (and only one) @ exists in the given string. This is mainly
163163
# to give user feedback and not to assert the e-mail validity.
164-
config.email_regexp = Regexp.new(ApiUmbrellaConfig[:web][:admin][:email_regex])
164+
config.email_regexp = ::Regexp.new(ApiUmbrellaConfig[:web][:admin][:email_regex], ::Regexp::IGNORECASE)
165165

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

0 commit comments

Comments
 (0)