Skip to content

Commit 8081f5d

Browse files
Gargronhiyuki2578
authored andcommitted
Fix LDAP/PAM/SAML/CAS users not being approved instantly (mastodon#10621)
1 parent 81b7177 commit 8081f5d

4 files changed

Lines changed: 9 additions & 1 deletion

File tree

app/models/concerns/ldap_authenticable.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module LdapAuthenticable
66
def ldap_setup(_attributes)
77
self.confirmed_at = Time.now.utc
88
self.admin = false
9+
self.external = true
910

1011
save!
1112
end

app/models/concerns/omniauthable.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def user_params_from_auth(auth)
6666
email: email || "#{TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com",
6767
password: Devise.friendly_token[0, 20],
6868
agreement: true,
69+
external: true,
6970
account_attributes: {
7071
username: ensure_unique_username(auth.uid),
7172
display_name: display_name,

app/models/concerns/pam_authenticable.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def pam_setup(_attributes)
3434
self.confirmed_at = Time.now.utc
3535
self.admin = false
3636
self.account = account
37+
self.external = true
3738

3839
account.destroy! unless save
3940
end

app/models/user.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class User < ApplicationRecord
107107
:expand_spoilers, :default_language, :aggregate_reblogs, :show_application, to: :settings, prefix: :setting, allow_nil: false
108108

109109
attr_reader :invite_code
110+
attr_writer :external
110111

111112
def confirmed?
112113
confirmed_at.present?
@@ -273,13 +274,17 @@ def send_devise_notification(notification, *args)
273274
private
274275

275276
def set_approved
276-
self.approved = open_registrations? || invited?
277+
self.approved = open_registrations? || invited? || external?
277278
end
278279

279280
def open_registrations?
280281
Setting.registrations_mode == 'open'
281282
end
282283

284+
def external?
285+
@external
286+
end
287+
283288
def sanitize_languages
284289
return if chosen_languages.nil?
285290
chosen_languages.reject!(&:blank?)

0 commit comments

Comments
 (0)