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
db23316e
Commit
db23316e
authored
Jul 12, 2021
by
Serena Fang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor block to separate method
parent
ce789a64
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
lib/gitlab/auth.rb
lib/gitlab/auth.rb
+10
-9
No files found.
lib/gitlab/auth.rb
View file @
db23316e
...
...
@@ -190,7 +190,6 @@ module Gitlab
end
end
# rubocop: disable CodeReuse/ActiveRecord
def
personal_access_token_check
(
password
,
project
)
return
unless
password
.
present?
...
...
@@ -200,19 +199,21 @@ module Gitlab
return
unless
valid_scoped_token?
(
token
,
all_available_scopes
)
if
project
&&
token
.
user
.
project_bot?
&&
!
project
.
bots
.
include?
(
token
.
user
)
return
unless
project
.
group
group_ancestor_ids
=
project
.
group
.
self_and_ancestors
.
pluck
(
:id
)
user_group_ids
=
token
.
user
.
groups
.
pluck
(
:id
)
return
if
(
group_ancestor_ids
&
user_group_ids
).
empty?
end
return
unless
token_bot_in_resource
(
token
,
project
)
if
can_user_login_with_non_expired_password?
(
token
.
user
)
||
token
.
user
.
project_bot?
Gitlab
::
Auth
::
Result
.
new
(
token
.
user
,
nil
,
:personal_access_token
,
abilities_for_scopes
(
token
.
scopes
))
end
end
# rubocop: disable CodeReuse/ActiveRecord
def
token_bot_in_resource
(
token
,
project
)
return
true
unless
project
&&
token
.
user
.
project_bot?
&&
!
project
.
bots
.
include?
(
token
.
user
)
return
false
unless
project
.
group
project
.
group
.
self_and_ancestors
.
where
(
id:
token
.
user
.
groups
).
exists?
end
# rubocop: enable CodeReuse/ActiveRecord
def
valid_oauth_token?
(
token
)
...
...
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