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
Léo-Paul Géneau
gitlab-ce
Commits
8b6154c1
Commit
8b6154c1
authored
Aug 24, 2016
by
Drew Blessing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor edits to two_factor_recovery_codes API error catching
parent
0e3c7b2f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
lib/api/internal.rb
lib/api/internal.rb
+9
-5
spec/requests/api/internal_spec.rb
spec/requests/api/internal_spec.rb
+2
-2
No files found.
lib/api/internal.rb
View file @
8b6154c1
...
...
@@ -105,15 +105,19 @@ module API
post
'/two_factor_recovery_codes'
do
status
200
key
=
Key
.
find
(
params
[
:key_id
])
user
=
key
.
user
key
=
Key
.
find_by
(
id:
params
[
:key_id
])
unless
key
return
{
'success'
=>
false
,
'message'
=>
'Could not find the given key'
}
end
# Make sure this isn't a deploy key
unless
key
.
type
.
nil?
if
key
.
is_a?
(
DeployKey
)
return
{
success:
false
,
message:
'Deploy keys cannot be used to retrieve recovery codes'
}
end
unless
user
.
present?
user
=
key
.
user
unless
user
return
{
success:
false
,
message:
'Could not find a user for the given key'
}
end
...
...
spec/requests/api/internal_spec.rb
View file @
8b6154c1
...
...
@@ -44,8 +44,8 @@ describe API::API, api: true do
secret_token:
secret_token
,
key_id:
12345
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'
404 Not found
'
)
expect
(
json_response
[
'success'
]).
to
be_falsey
expect
(
json_response
[
'message'
]).
to
eq
(
'
Could not find the given key
'
)
end
it
'returns an error message when the key is a deploy key'
do
...
...
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