summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-29 19:57:17 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-29 19:57:17 +0000
commit37e3c3bb33c3d331fceb2840cf3c1d3c466dcfa9 (patch)
tree9d3739f627b491b42ede6424acd11b589beed25f /lib
parentb55baf593e63db9be3f446ea0cca0281a69dd2e2 (diff)
downloadgitlab-ce-37e3c3bb33c3d331fceb2840cf3c1d3c466dcfa9.tar.gz
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'lib')
-rw-r--r--lib/api/settings.rb3
-rw-r--r--lib/api/validations/types/hash_of_integer_values.rb20
-rw-r--r--lib/gitlab/auth/user_access_denied_reason.rb6
-rw-r--r--lib/gitlab/background_migration/wrongfully_confirmed_email_unconfirmer.rb1
4 files changed, 28 insertions, 2 deletions
diff --git a/lib/api/settings.rb b/lib/api/settings.rb
index 3463e29041b..f2e0aaecfb9 100644
--- a/lib/api/settings.rb
+++ b/lib/api/settings.rb
@@ -114,8 +114,7 @@ module API
requires :recaptcha_private_key, type: String, desc: 'Generate private key at http://www.google.com/recaptcha'
end
optional :repository_checks_enabled, type: Boolean, desc: "GitLab will periodically run 'git fsck' in all project and wiki repositories to look for silent disk corruption issues."
- optional :repository_storages, type: Array[String], coerce_with: Validations::Types::CommaSeparatedToArray.coerce, desc: 'Storage paths for new projects'
- optional :repository_storages_weighted, type: Hash, desc: 'Storage paths for new projects with a weighted value between 0 and 100'
+ optional :repository_storages_weighted, type: Hash, coerce_with: Validations::Types::HashOfIntegerValues.coerce, desc: 'Storage paths for new projects with a weighted value ranging from 0 to 100'
optional :require_two_factor_authentication, type: Boolean, desc: 'Require all users to set up Two-factor authentication'
given require_two_factor_authentication: ->(val) { val } do
requires :two_factor_grace_period, type: Integer, desc: 'Amount of time (in hours) that users are allowed to skip forced configuration of two-factor authentication'
diff --git a/lib/api/validations/types/hash_of_integer_values.rb b/lib/api/validations/types/hash_of_integer_values.rb
new file mode 100644
index 00000000000..05821acfad5
--- /dev/null
+++ b/lib/api/validations/types/hash_of_integer_values.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+module API
+ module Validations
+ module Types
+ class HashOfIntegerValues
+ def self.coerce
+ lambda do |value|
+ case value
+ when Hash
+ value.transform_values(&:to_i)
+ else
+ value
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/auth/user_access_denied_reason.rb b/lib/gitlab/auth/user_access_denied_reason.rb
index e73f6ca808c..cc4b8d887ff 100644
--- a/lib/gitlab/auth/user_access_denied_reason.rb
+++ b/lib/gitlab/auth/user_access_denied_reason.rb
@@ -17,6 +17,10 @@ module Gitlab
when :deactivated
"Your account has been deactivated by your administrator. "\
"Please log back in from a web browser to reactivate your account at #{Gitlab.config.gitlab.url}"
+ when :unconfirmed
+ "Your primary email address is not confirmed. "\
+ "Please check your inbox for the confirmation instructions. "\
+ "In case the link is expired, you can request a new confirmation email at #{Rails.application.routes.url_helpers.new_user_confirmation_url}"
else
"Your account has been blocked."
end
@@ -31,6 +35,8 @@ module Gitlab
:terms_not_accepted
elsif @user.deactivated?
:deactivated
+ elsif !@user.confirmed?
+ :unconfirmed
else
:blocked
end
diff --git a/lib/gitlab/background_migration/wrongfully_confirmed_email_unconfirmer.rb b/lib/gitlab/background_migration/wrongfully_confirmed_email_unconfirmer.rb
index 5f63cf5836e..baacc912df3 100644
--- a/lib/gitlab/background_migration/wrongfully_confirmed_email_unconfirmer.rb
+++ b/lib/gitlab/background_migration/wrongfully_confirmed_email_unconfirmer.rb
@@ -30,6 +30,7 @@ module Gitlab
.where('emails.confirmed_at IS NOT NULL')
.where('emails.confirmed_at = users.confirmed_at')
.where('emails.email <> users.email')
+ .where('NOT EXISTS (SELECT 1 FROM user_synced_attributes_metadata WHERE user_id=users.id AND email_synced IS true)')
end
end