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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
c0229e46
Commit
c0229e46
authored
Oct 08, 2014
by
Jan-Willem van der Meer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt ldap_user? to multiple ldap providers
parent
6059e068
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
app/models/user.rb
app/models/user.rb
+2
-2
spec/models/user_spec.rb
spec/models/user_spec.rb
+19
-0
No files found.
app/models/user.rb
View file @
c0229e46
...
...
@@ -176,7 +176,7 @@ class User < ActiveRecord::Base
scope
:not_in_team
,
->
(
team
){
where
(
'users.id NOT IN (:ids)'
,
ids:
team
.
member_ids
)
}
scope
:not_in_project
,
->
(
project
)
{
project
.
users
.
present?
?
where
(
"id not in (:ids)"
,
ids:
project
.
users
.
map
(
&
:id
)
)
:
all
}
scope
:without_projects
,
->
{
where
(
'id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)'
)
}
scope
:ldap
,
->
{
where
(
provider:
'ldap
'
)
}
scope
:ldap
,
->
{
where
(
'provider LIKE ?'
,
'ldap%
'
)
}
scope
:subscribed_for_admin_email
,
->
{
where
(
admin_email_unsubscribed_at:
nil
)
}
scope
:potential_team_members
,
->
(
team
)
{
team
.
members
.
any?
?
active
.
not_in_team
(
team
)
:
active
}
...
...
@@ -397,7 +397,7 @@ class User < ActiveRecord::Base
end
def
ldap_user?
extern_uid
&&
provider
==
'ldap'
extern_uid
&&
provider
.
start_with?
(
'ldap'
)
end
def
accessible_deploy_keys
...
...
spec/models/user_spec.rb
View file @
c0229e46
...
...
@@ -346,6 +346,25 @@ describe User do
end
end
describe
:ldap_user?
do
let
(
:user
)
{
build
(
:user
,
:ldap
)
}
it
"is true if provider name starts with ldap"
do
user
.
provider
=
'ldapmain'
expect
(
user
.
ldap_user?
).
to
be_true
end
it
"is false for other providers"
do
user
.
provider
=
'other-provider'
expect
(
user
.
ldap_user?
).
to
be_false
end
it
"is false if no extern_uid is provided"
do
user
.
extern_uid
=
nil
expect
(
user
.
ldap_user?
).
to
be_false
end
end
describe
'#full_website_url'
do
let
(
:user
)
{
create
(
:user
)
}
...
...
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