BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
c2978008
Commit
c2978008
authored
Aug 17, 2016
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed unnecessary service for user retrieval and improved API error message.
parent
ff6f0ada
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
3 additions
and
34 deletions
+3
-34
user_retrieval_service.rb
app/services/user_retrieval_service.rb
+0
-13
doorkeeper.rb
config/initializers/doorkeeper.rb
+2
-1
helpers.rb
lib/api/helpers.rb
+1
-1
user_retrieval_service_spec.rb
spec/services/user_retrieval_service_spec.rb
+0
-19
No files found.
app/services/user_retrieval_service.rb
deleted
100644 → 0
View file @
ff6f0ada
class
UserRetrievalService
attr_accessor
:login
,
:password
def
initialize
(
login
,
password
)
@login
=
login
@password
=
password
end
def
execute
user
=
Gitlab
::
Auth
.
find_with_user_password
(
login
,
password
)
user
unless
user
.
two_factor_enabled?
end
end
config/initializers/doorkeeper.rb
View file @
c2978008
...
...
@@ -12,7 +12,8 @@ Doorkeeper.configure do
end
resource_owner_from_credentials
do
|
routes
|
UserRetrievalService
.
new
(
params
[
:username
],
params
[
:password
]).
execute
user
=
Gitlab
::
Auth
.
find_with_user_password
(
params
[
:username
],
params
[
:password
])
user
unless
user
&&
user
.
two_factor_enabled?
end
# If you want to restrict access to the web interface for adding oauth authorized applications, you need to declare the block below.
...
...
lib/api/helpers.rb
View file @
c2978008
...
...
@@ -276,7 +276,7 @@ module API
end
def
render_2fa_error!
render_api_error!
(
'401 You have 2FA enabled. Please use a personal access token to access the API'
,
401
)
render_api_error!
(
'401
Unauthorized.
You have 2FA enabled. Please use a personal access token to access the API'
,
401
)
end
def
render_api_error!
(
message
,
status
)
...
...
spec/services/user_retrieval_service_spec.rb
deleted
100644 → 0
View file @
ff6f0ada
require
'spec_helper'
describe
UserRetrievalService
,
services:
true
do
context
'user retrieval'
do
it
'retrieves the correct user'
do
user
=
create
(
:user
)
retrieved_user
=
described_class
.
new
(
user
.
username
,
user
.
password
).
execute
expect
(
retrieved_user
).
to
eq
(
user
)
end
it
'returns nil when 2FA is enabled'
do
user
=
create
(
:user
,
:two_factor
)
retrieved_user
=
described_class
.
new
(
user
.
username
,
user
.
password
).
execute
expect
(
retrieved_user
).
to
be_nil
end
end
end
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