Skip to content

Commit cbfb54f

Browse files
authored
Update plugin.rb
1 parent 4ab9a09 commit cbfb54f

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

plugin.rb

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,19 @@ def enabled?
2828

2929
def after_authenticate(auth_token, existing_account: nil)
3030
Rails.logger.info("after_authenticate called")
31-
result = super(auth_token, existing_account: existing_account)
32-
if existing_account
33-
association = UserAssociatedAccount.find_by(user_id: existing_account.id, provider_name: auth_token[:provider], provider_uid: auth_token[:uid])
34-
if association.nil?
35-
Rails.logger.info("no associated_account found for this uuid")
36-
result.email_valid = false
37-
end
31+
32+
association = UserAssociatedAccount.find_by(provider_name: auth_token[:provider], provider_uid: auth_token[:uid])
33+
34+
if !association.nil?
35+
Rails.logger.info("associated_account #{association.info["email"]} found for this uuid")
36+
user = association&.user
37+
Rails.logger.info("found user #{user.inspect}")
38+
result = super(auth_token, existing_account: existing_account)
39+
else
40+
Rails.logger.info("no associated_account found for this uuid")
41+
result.email_valid = false
42+
result.failed = true
43+
result.failed_reason = "wrong uuid on associated account"
3844
end
3945

4046
result

0 commit comments

Comments
 (0)