Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
23afb02a
Commit
23afb02a
authored
Jul 16, 2016
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor `match_domain` to a predicate: `domain_matches?`
parent
c71e658c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
app/models/user.rb
app/models/user.rb
+3
-3
No files found.
app/models/user.rb
View file @
23afb02a
...
...
@@ -865,7 +865,7 @@ class User < ActiveRecord::Base
if
current_application_settings
.
domain_blacklist_enabled?
blocked_domains
=
current_application_settings
.
domain_blacklist
if
match_domain
(
blocked_domains
,
self
.
email
)
if
domain_matches?
(
blocked_domains
,
self
.
email
)
error
=
'is not from an allowed domain.'
valid
=
false
end
...
...
@@ -873,7 +873,7 @@ class User < ActiveRecord::Base
allowed_domains
=
current_application_settings
.
domain_whitelist
unless
allowed_domains
.
blank?
if
match_domain
(
allowed_domains
,
self
.
email
)
if
domain_matches?
(
allowed_domains
,
self
.
email
)
valid
=
true
else
error
=
"is not whitelisted. Email domains valid for registration are:
#{
allowed_domains
.
join
(
', '
)
}
"
...
...
@@ -886,7 +886,7 @@ class User < ActiveRecord::Base
valid
end
def
match_domain
(
email_domains
,
email
)
def
domain_matches?
(
email_domains
,
email
)
signup_domain
=
Mail
::
Address
.
new
(
email
).
domain
email_domains
.
any?
do
|
domain
|
escaped
=
Regexp
.
escape
(
domain
).
gsub
(
'\*'
,
'.*?'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment