summaryrefslogtreecommitdiff
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /app/models/user.rb
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
downloadgitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb23
1 files changed, 17 insertions, 6 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index ce702131151..80b8c9173d1 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -375,6 +375,10 @@ class User < ApplicationRecord
Ci::DropPipelineService.new.execute_async_for_all(user.pipelines, :user_blocked, user)
Ci::DisableUserPipelineSchedulesService.new.execute(user)
end
+
+ after_transition any => :deactivated do |user|
+ NotificationService.new.user_deactivated(user.name, user.notification_email)
+ end
# rubocop: enable CodeReuse/ServiceClass
end
@@ -430,6 +434,7 @@ class User < ApplicationRecord
scope :by_id_and_login, ->(id, login) { where(id: id).where('username = LOWER(:login) OR email = LOWER(:login)', login: login) }
scope :dormant, -> { active.where('last_activity_on <= ?', MINIMUM_INACTIVE_DAYS.day.ago.to_date) }
scope :with_no_activity, -> { active.where(last_activity_on: nil) }
+ scope :by_provider_and_extern_uid, ->(provider, extern_uid) { joins(:identities).merge(Identity.with_extern_uid(provider, extern_uid)) }
def preferred_language
read_attribute('preferred_language') ||
@@ -554,10 +559,6 @@ class User < ApplicationRecord
end
end
- def for_github_id(id)
- joins(:identities).merge(Identity.with_extern_uid(:github, id))
- end
-
# Find a User by their primary email or any associated secondary email
def find_by_any_email(email, confirmed: false)
return unless email
@@ -809,6 +810,10 @@ class User < ApplicationRecord
# Instance methods
#
+ def default_dashboard?
+ dashboard == self.class.column_defaults['dashboard']
+ end
+
def full_path
username
end
@@ -1231,7 +1236,7 @@ class User < ApplicationRecord
end
def matches_identity?(provider, extern_uid)
- identities.where(provider: provider, extern_uid: extern_uid).exists?
+ identities.with_extern_uid(provider, extern_uid).exists?
end
def project_deploy_keys
@@ -1300,6 +1305,10 @@ class User < ApplicationRecord
save if notification_email_changed? || public_email_changed? || commit_email_changed?
end
+ def admin_unsubscribe!
+ update_column :admin_email_unsubscribed_at, Time.current
+ end
+
def set_projects_limit
# `User.select(:id)` raises
# `ActiveModel::MissingAttributeError: missing attribute: projects_limit`
@@ -1882,9 +1891,11 @@ class User < ApplicationRecord
end
def password_expired_if_applicable?
+ return false if bot?
+ return false unless password_expired? && password_automatically_set?
return false unless allow_password_authentication?
- password_expired?
+ true
end
def can_be_deactivated?