Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix “invited by” not showing up for invited accounts in admin interface #10791

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def confirmed?
end

def invited?
invite_id.present?
end

def valid_invitation?
invite_id.present? && invite.valid_for_use?
end

Expand Down Expand Up @@ -274,7 +278,7 @@ def send_devise_notification(notification, *args)
private

def set_approved
self.approved = open_registrations? || invited? || external?
self.approved = open_registrations? || valid_invitation? || external?
end

def open_registrations?
Expand Down
2 changes: 1 addition & 1 deletion app/validators/blacklisted_email_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class BlacklistedEmailValidator < ActiveModel::Validator
def validate(user)
return if user.invited?
return if user.valid_invitation?

@email = user.email

Expand Down
2 changes: 1 addition & 1 deletion spec/validators/blacklisted_email_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let(:errors) { double(add: nil) }

before do
allow(user).to receive(:invited?) { false }
allow(user).to receive(:valid_invitation?) { false }
allow_any_instance_of(described_class).to receive(:blocked_email?) { blocked_email }
described_class.new.validate(user)
end
Expand Down