A platform for community discussion. Free, open, simple.
FIX: Ensure that login does not fail for users with invite records (#15647)
David Taylor820564826e99
diff --git a/app/models/invite.rb b/app/models/invite.rbindex e64f4c69bd2..1594a109ab4 100644--- a/app/models/invite.rb+++ b/app/models/invite.rb@@ -32,7 +32,7 @@ class Invite < ActiveRecord::Basevalidates :email, email: true, allow_blank: truevalidate :ensure_max_redemptions_allowedvalidate :valid_domain, if: :will_save_change_to_domain?- validate :user_doesnt_already_exist+ validate :user_doesnt_already_exist, if: :will_save_change_to_email?before_create doself.invite_key ||= SecureRandom.base58(10)diff --git a/spec/requests/omniauth_callbacks_controller_spec.rb b/spec/requests/omniauth_callbacks_controller_spec.rbindex 4f7cbd4fe07..46f81b1d997 100644--- a/spec/requests/omniauth_callbacks_controller_spec.rb+++ b/spec/requests/omniauth_callbacks_controller_spec.rb@@ -411,6 +411,20 @@ RSpec.describe Users::OmniauthCallbacksController doexpect(user.confirm_password?("securepassword")).to eq(false)end+ it "should work if the user has no email_tokens, and an invite" do+ # Confirming existing email_tokens has a side effect of redeeming invites.+ # Pretend we don't have any email_tokens+ user.email_tokens.destroy_all++ invite = Fabricate(:invite, invited_by: Fabricate(:admin))+ invite.update_column(:email, user.email) # (avoid validation)++ get "/auth/google_oauth2/callback.json"+ expect(response.status).to eq(302)++ expect(invite.reload.invalidated_at).not_to eq(nil)+ end+it "should update name/username/email when SiteSetting.auth_overrides_* are enabled" doSiteSetting.email_editable = falseSiteSetting.auth_overrides_email = true