Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-08 18:06:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-08 18:06:21 +0300
commit759bab058520a21d87087355dc193f634176e98a (patch)
treec26bdab0be782b6852e5f588dc5f1b056c2eec56 /app/services/users
parent61f0c58946ebac453b55a657cd4be1ac50a01e11 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/users')
-rw-r--r--app/services/users/signup_service.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/services/users/signup_service.rb b/app/services/users/signup_service.rb
new file mode 100644
index 00000000000..1031cec44cb
--- /dev/null
+++ b/app/services/users/signup_service.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+module Users
+ class SignupService < BaseService
+ def initialize(current_user, params = {})
+ @user = current_user
+ @params = params.dup
+ end
+
+ def execute
+ assign_attributes
+ inject_validators
+
+ if @user.save
+ success
+ else
+ error(@user.errors.full_messages.join('. '))
+ end
+ end
+
+ private
+
+ def assign_attributes
+ @user.assign_attributes(params) unless params.empty?
+ end
+
+ def inject_validators
+ class << @user
+ validates :role, presence: true
+ validates :setup_for_company, inclusion: { in: [true, false], message: :blank }
+ end
+ end
+ end
+end