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:
Diffstat (limited to 'app/services/users')
-rw-r--r--app/services/users/activity_service.rb4
-rw-r--r--app/services/users/authorized_build_service.rb2
-rw-r--r--app/services/users/build_service.rb4
-rw-r--r--app/services/users/destroy_service.rb11
-rw-r--r--app/services/users/migrate_records_to_ghost_user_in_batches_service.rb8
-rw-r--r--app/services/users/migrate_records_to_ghost_user_service.rb2
-rw-r--r--app/services/users/refresh_authorized_projects_service.rb20
-rw-r--r--app/services/users/upsert_credit_card_validation_service.rb8
8 files changed, 32 insertions, 27 deletions
diff --git a/app/services/users/activity_service.rb b/app/services/users/activity_service.rb
index 24aa4aa1061..b490df6a134 100644
--- a/app/services/users/activity_service.rb
+++ b/app/services/users/activity_service.rb
@@ -30,11 +30,9 @@ module Users
return if Gitlab::Database.read_only?
today = Date.today
-
return if user.last_activity_on == today
- lease = Gitlab::ExclusiveLease.new("activity_service:#{user.id}",
- timeout: LEASE_TIMEOUT)
+ lease = Gitlab::ExclusiveLease.new("activity_service:#{user.id}", timeout: LEASE_TIMEOUT)
return unless lease.try_obtain
user.update_attribute(:last_activity_on, today)
diff --git a/app/services/users/authorized_build_service.rb b/app/services/users/authorized_build_service.rb
index 5029105b087..446c897fe5a 100644
--- a/app/services/users/authorized_build_service.rb
+++ b/app/services/users/authorized_build_service.rb
@@ -12,7 +12,7 @@ module Users
end
def signup_params
- super + [:skip_confirmation]
+ super + [:skip_confirmation, :external]
end
end
end
diff --git a/app/services/users/build_service.rb b/app/services/users/build_service.rb
index 04a11f41eb1..b51684c6899 100644
--- a/app/services/users/build_service.rb
+++ b/app/services/users/build_service.rb
@@ -5,8 +5,8 @@ module Users
ALLOWED_USER_TYPES = %i[project_bot security_policy_bot].freeze
delegate :user_default_internal_regex_enabled?,
- :user_default_internal_regex_instance,
- to: :'Gitlab::CurrentSettings.current_application_settings'
+ :user_default_internal_regex_instance,
+ to: :'Gitlab::CurrentSettings.current_application_settings'
def initialize(current_user, params = {})
@current_user = current_user
diff --git a/app/services/users/destroy_service.rb b/app/services/users/destroy_service.rb
index d4c00a4dcec..a0e1167836b 100644
--- a/app/services/users/destroy_service.rb
+++ b/app/services/users/destroy_service.rb
@@ -59,9 +59,6 @@ module Users
Groups::DestroyService.new(group, current_user).execute
end
- namespace = user.namespace
- namespace.prepare_for_destroy
-
user.personal_projects.each do |project|
success = ::Projects::DestroyService.new(project, current_user).execute
raise DestroyError, "Project #{project.id} can't be deleted" unless success
@@ -70,9 +67,11 @@ module Users
yield(user) if block_given?
hard_delete = options.fetch(:hard_delete, false)
- Users::GhostUserMigration.create!(user: user,
- initiator_user: current_user,
- hard_delete: hard_delete)
+ Users::GhostUserMigration.create!(
+ user: user,
+ initiator_user: current_user,
+ hard_delete: hard_delete
+ )
update_metrics
end
diff --git a/app/services/users/migrate_records_to_ghost_user_in_batches_service.rb b/app/services/users/migrate_records_to_ghost_user_in_batches_service.rb
index d294312cc30..e05f308343d 100644
--- a/app/services/users/migrate_records_to_ghost_user_in_batches_service.rb
+++ b/app/services/users/migrate_records_to_ghost_user_in_batches_service.rb
@@ -12,9 +12,11 @@ module Users
ghost_user_migrations.each do |job|
break if execution_tracker.over_limit?
- service = Users::MigrateRecordsToGhostUserService.new(job.user,
- job.initiator_user,
- execution_tracker)
+ service = Users::MigrateRecordsToGhostUserService.new(
+ job.user,
+ job.initiator_user,
+ execution_tracker
+ )
service.execute(hard_delete: job.hard_delete)
rescue Gitlab::Utils::ExecutionTracker::ExecutionTimeOutError
# no-op
diff --git a/app/services/users/migrate_records_to_ghost_user_service.rb b/app/services/users/migrate_records_to_ghost_user_service.rb
index 5d518803315..06950292fea 100644
--- a/app/services/users/migrate_records_to_ghost_user_service.rb
+++ b/app/services/users/migrate_records_to_ghost_user_service.rb
@@ -18,7 +18,7 @@ module Users
@user = user
@initiator_user = initiator_user
@execution_tracker = execution_tracker
- @ghost_user = User.ghost
+ @ghost_user = Users::Internal.ghost
end
def execute(hard_delete: false)
diff --git a/app/services/users/refresh_authorized_projects_service.rb b/app/services/users/refresh_authorized_projects_service.rb
index 197260a80ca..32acc3f170d 100644
--- a/app/services/users/refresh_authorized_projects_service.rb
+++ b/app/services/users/refresh_authorized_projects_service.rb
@@ -82,15 +82,17 @@ module Users
attr_reader :incorrect_auth_found_callback, :missing_auth_found_callback
def log_refresh_details(remove, add)
- Gitlab::AppJsonLogger.info(event: 'authorized_projects_refresh',
- user_id: user.id,
- 'authorized_projects_refresh.source': source,
- 'authorized_projects_refresh.rows_deleted_count': remove.length,
- 'authorized_projects_refresh.rows_added_count': add.length,
- # most often there's only a few entries in remove and add, but limit it to the first 5
- # entries to avoid flooding the logs
- 'authorized_projects_refresh.rows_deleted_slice': remove.first(5),
- 'authorized_projects_refresh.rows_added_slice': add.first(5).map(&:values))
+ Gitlab::AppJsonLogger.info(
+ event: 'authorized_projects_refresh',
+ user_id: user.id,
+ 'authorized_projects_refresh.source': source,
+ 'authorized_projects_refresh.rows_deleted_count': remove.length,
+ 'authorized_projects_refresh.rows_added_count': add.length,
+ # most often there's only a few entries in remove and add, but limit it to the first 5
+ # entries to avoid flooding the logs
+ 'authorized_projects_refresh.rows_deleted_slice': remove.first(5),
+ 'authorized_projects_refresh.rows_added_slice': add.first(5).map(&:values)
+ )
end
end
end
diff --git a/app/services/users/upsert_credit_card_validation_service.rb b/app/services/users/upsert_credit_card_validation_service.rb
index 61cf598f178..62df676db25 100644
--- a/app/services/users/upsert_credit_card_validation_service.rb
+++ b/app/services/users/upsert_credit_card_validation_service.rb
@@ -7,8 +7,10 @@ module Users
end
def execute
+ user_id = params.fetch(:user_id)
+
@params = {
- user_id: params.fetch(:user_id),
+ user_id: user_id,
credit_card_validated_at: params.fetch(:credit_card_validated_at),
expiration_date: get_expiration_date(params),
last_digits: Integer(params.fetch(:credit_card_mask_number), 10),
@@ -16,7 +18,9 @@ module Users
holder_name: params.fetch(:credit_card_holder_name)
}
- ::Users::CreditCardValidation.upsert(@params)
+ credit_card = Users::CreditCardValidation.find_or_initialize_by_user(user_id)
+
+ credit_card.update(@params.except(:user_id))
ServiceResponse.success(message: 'CreditCardValidation was set')
rescue ActiveRecord::InvalidForeignKey, ActiveRecord::NotNullViolation => e