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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
e15fa67c
Commit
e15fa67c
authored
Jul 15, 2016
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure email domain validation method is private.
parent
ce58437c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
28 deletions
+26
-28
app/models/user.rb
app/models/user.rb
+26
-28
No files found.
app/models/user.rb
View file @
e15fa67c
...
@@ -760,33 +760,6 @@ class User < ActiveRecord::Base
...
@@ -760,33 +760,6 @@ class User < ActiveRecord::Base
Project
.
where
(
id:
events
)
Project
.
where
(
id:
events
)
end
end
def
signup_domain_valid?
valid
=
true
error
=
nil
if
current_application_settings
.
domain_blacklist_enabled?
blocked_domains
=
current_application_settings
.
domain_blacklist
if
match_domain
(
blocked_domains
,
self
.
email
)
error
=
'is not from an allowed domain.'
valid
=
false
end
end
allowed_domains
=
current_application_settings
.
restricted_signup_domains
unless
allowed_domains
.
blank?
if
match_domain
(
allowed_domains
,
self
.
email
)
valid
=
true
else
error
=
"is not whitelisted. Email domains valid for registration are:
#{
allowed_domains
.
join
(
', '
)
}
"
valid
=
false
end
end
self
.
errors
.
add
(
:email
,
error
)
unless
valid
valid
end
def
can_be_removed?
def
can_be_removed?
!
solo_owned_groups
.
present?
!
solo_owned_groups
.
present?
end
end
...
@@ -886,7 +859,32 @@ class User < ActiveRecord::Base
...
@@ -886,7 +859,32 @@ class User < ActiveRecord::Base
self
.
projects_limit
=
0
self
.
projects_limit
=
0
end
end
private
def
signup_domain_valid?
valid
=
true
error
=
nil
if
current_application_settings
.
domain_blacklist_enabled?
blocked_domains
=
current_application_settings
.
domain_blacklist
if
match_domain
(
blocked_domains
,
self
.
email
)
error
=
'is not from an allowed domain.'
valid
=
false
end
end
allowed_domains
=
current_application_settings
.
restricted_signup_domains
unless
allowed_domains
.
blank?
if
match_domain
(
allowed_domains
,
self
.
email
)
valid
=
true
else
error
=
"is not whitelisted. Email domains valid for registration are:
#{
allowed_domains
.
join
(
', '
)
}
"
valid
=
false
end
end
self
.
errors
.
add
(
:email
,
error
)
unless
valid
valid
end
def
match_domain
(
email_domains
,
email
)
def
match_domain
(
email_domains
,
email
)
signup_domain
=
Mail
::
Address
.
new
(
email
).
domain
signup_domain
=
Mail
::
Address
.
new
(
email
).
domain
...
...
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