summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/project_wiki.rb1
-rw-r--r--app/models/snippet.rb2
-rw-r--r--app/models/user.rb28
3 files changed, 22 insertions, 9 deletions
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index 50ce1c67453..f0967b87345 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -39,6 +39,7 @@ class ProjectWiki
def full_path
@project.full_path + '.wiki'
end
+ alias_method :id, :full_path
# @deprecated use full_path when you need it for an URL route or disk_path when you want to point to the filesystem
alias_method :path_with_namespace, :full_path
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index edf524190e4..973bdc54111 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -310,7 +310,7 @@ class Snippet < ApplicationRecord
end
def versioned_enabled_for?(user)
- repository_exists? && ::Feature.enabled?(:version_snippets, user)
+ ::Feature.enabled?(:version_snippets, user) && repository_exists?
end
class << self
diff --git a/app/models/user.rb b/app/models/user.rb
index 4d450f9305f..343edfae799 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -58,6 +58,8 @@ class User < ApplicationRecord
BLOCKED_MESSAGE = "Your account has been blocked. Please contact your GitLab " \
"administrator if you think this is an error."
+ LOGIN_FORBIDDEN = "Your account does not have the required permission to login. Please contact your GitLab " \
+ "administrator if you think this is an error."
MINIMUM_INACTIVE_DAYS = 180
@@ -299,14 +301,6 @@ class User < ApplicationRecord
def blocked?
true
end
-
- def active_for_authentication?
- false
- end
-
- def inactive_message
- BLOCKED_MESSAGE
- end
end
before_transition do
@@ -354,6 +348,20 @@ class User < ApplicationRecord
.expiring_and_not_notified(at).select(1))
end
+ def active_for_authentication?
+ super && can?(:log_in)
+ end
+
+ def inactive_message
+ if blocked?
+ BLOCKED_MESSAGE
+ elsif internal?
+ LOGIN_FORBIDDEN
+ else
+ super
+ end
+ end
+
def self.with_visible_profile(user)
return with_public_profile if user.nil?
@@ -1701,6 +1709,10 @@ class User < ApplicationRecord
members.non_request.maximum(:access_level)
end
+ def confirmation_required_on_sign_in?
+ !confirmed? && !confirmation_period_valid?
+ end
+
protected
# override, from Devise::Validatable