diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-03 12:08:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-03 12:08:47 +0300 |
commit | 31a432e38a8b70d3ffb16afa8d7cfeee4f5f5921 (patch) | |
tree | b59f8b4e2ef7486f13adb01328a749f19b93a023 /app/serializers | |
parent | 6b7b853dff4cb7e72d76bd501d75708111c95585 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/service_field_entity.rb | 24 | ||||
-rw-r--r-- | app/serializers/service_field_serializer.rb | 5 |
2 files changed, 29 insertions, 0 deletions
diff --git a/app/serializers/service_field_entity.rb b/app/serializers/service_field_entity.rb new file mode 100644 index 00000000000..9929d7e2e5a --- /dev/null +++ b/app/serializers/service_field_entity.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class ServiceFieldEntity < Grape::Entity + include RequestAwareEntity + + expose :type, :name, :title, :placeholder, :required, :choices, :help + + expose :value do |field| + # field[:name] is not user input and so can assume is safe + value = service.public_send(field[:name]) # rubocop:disable GitlabSecurity/PublicSend + + if field[:type] == 'password' && value.present? + 'true' + else + value + end + end + + private + + def service + request.service + end +end diff --git a/app/serializers/service_field_serializer.rb b/app/serializers/service_field_serializer.rb new file mode 100644 index 00000000000..120d0f5820e --- /dev/null +++ b/app/serializers/service_field_serializer.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class ServiceFieldSerializer < BaseSerializer + entity ServiceFieldEntity +end |