about summary refs log tree commit diff
path: root/app/validators/unreserved_username_validator.rb
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-02-02 08:39:52 -0600
committerDavid Yip <yipdw@member.fsf.org>2018-02-02 08:39:52 -0600
commit4c1fd9a19c779fa6e7d74513c61f37ce05a841b3 (patch)
tree0cf23810e2f7ff0f45c65a3f2f9b35016587c68a /app/validators/unreserved_username_validator.rb
parentad3a2dfb66abc01a90807f23191b7e28c3c242ed (diff)
parent33f56811e38bc330de9dcfa6794c29a176a30311 (diff)
Merge remote-tracking branch 'tootsuite/master' into merge-upstream
Conflicts:
      app/javascript/styles/mastodon/components.scss
Diffstat (limited to 'app/validators/unreserved_username_validator.rb')
-rw-r--r--app/validators/unreserved_username_validator.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/validators/unreserved_username_validator.rb b/app/validators/unreserved_username_validator.rb
index 44ea4359b..c2311a89a 100644
--- a/app/validators/unreserved_username_validator.rb
+++ b/app/validators/unreserved_username_validator.rb
@@ -8,7 +8,13 @@ class UnreservedUsernameValidator < ActiveModel::Validator
 
   private
 
+  def pam_controlled?(value)
+    return false unless Devise.pam_authentication && Devise.pam_controlled_service
+    Rpam2.account(Devise.pam_controlled_service, value).present?
+  end
+
   def reserved_username?(value)
+    return true if pam_controlled?(value)
     return false unless Setting.reserved_usernames
     Setting.reserved_usernames.include?(value.downcase)
   end