diff options
author | Stan Hu <stanhu@gmail.com> | 2018-09-09 14:04:11 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-09-10 22:41:53 -0700 |
commit | ced2a932d75272e25f172b879b08de2208ce4b5c (patch) | |
tree | 6e05813f0d28d3ccf110823ec128d7257813a5c1 /app/services/emails | |
parent | 2f990e3408d00cad473d8dcf8a4e49155cc3cc33 (diff) | |
download | gitlab-ce-ced2a932d75272e25f172b879b08de2208ce4b5c.tar.gz |
Add ability to skip user email confirmation with API
This gives admins the ability to send a `skip_confirmation` flag in the
`POST /users/:id/email` API endpoint to skip the verification step and
assume the given e-mail address is verified.
Closes #50876
Diffstat (limited to 'app/services/emails')
-rw-r--r-- | app/services/emails/base_service.rb | 2 | ||||
-rw-r--r-- | app/services/emails/create_service.rb | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/app/services/emails/base_service.rb b/app/services/emails/base_service.rb index ba7b689a9af..988215ffc78 100644 --- a/app/services/emails/base_service.rb +++ b/app/services/emails/base_service.rb @@ -2,6 +2,8 @@ module Emails class BaseService + attr_reader :current_user + def initialize(current_user, params = {}) @current_user, @params = current_user, params.dup @user = params.delete(:user) diff --git a/app/services/emails/create_service.rb b/app/services/emails/create_service.rb index acf575e24e5..56925a724fe 100644 --- a/app/services/emails/create_service.rb +++ b/app/services/emails/create_service.rb @@ -3,7 +3,12 @@ module Emails class CreateService < ::Emails::BaseService def execute(extra_params = {}) - @user.emails.create(@params.merge(extra_params)) + skip_confirmation = @params.delete(:skip_confirmation) + + email = @user.emails.create(@params.merge(extra_params)) + + email&.confirm if skip_confirmation && current_user.admin? + email end end end |