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
bc8a5ec7
Commit
bc8a5ec7
authored
Jun 17, 2020
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use CreateService when an admin creates a new gpg key for a user
parent
318d5541
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
app/services/gpg_keys/create_service.rb
app/services/gpg_keys/create_service.rb
+8
-0
lib/api/users.rb
lib/api/users.rb
+2
-2
No files found.
app/services/gpg_keys/create_service.rb
View file @
bc8a5ec7
...
...
@@ -2,6 +2,14 @@
module
GpgKeys
class
CreateService
<
Keys
::
BaseService
attr_accessor
:current_user
def
initialize
(
current_user
,
params
=
{})
@current_user
,
@params
=
current_user
,
params
@ip_address
=
@params
.
delete
(
:ip_address
)
@user
=
params
.
delete
(
:user
)
||
current_user
end
def
execute
key
=
user
.
gpg_keys
.
create
(
params
)
notification_service
.
new_gpg_key
(
key
)
if
key
.
persisted?
...
...
lib/api/users.rb
View file @
bc8a5ec7
...
...
@@ -328,9 +328,9 @@ module API
user
=
User
.
find_by
(
id:
params
.
delete
(
:id
))
not_found!
(
'User'
)
unless
user
key
=
user
.
gpg_keys
.
new
(
declared_params
(
include_missing:
false
))
key
=
::
GpgKeys
::
CreateService
.
new
(
current_user
,
declared_params
(
include_missing:
false
).
merge
(
user:
user
)).
execute
if
key
.
save
if
key
.
persisted?
present
key
,
with:
Entities
::
GpgKey
else
render_validation_error!
(
key
)
...
...
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