Class: SpreeCmCommissioner::UserTelegramOauthAuthenticator

Inherits:
BaseInteractor
  • Object
show all
Defined in:
app/interactors/spree_cm_commissioner/user_telegram_oauth_authenticator.rb

Overview

Authenticates a user from a verified Telegram OIDC id_token. Resolution order mirrors the Firebase social-login flow (UserRegistrationWithIdToken):

1. a user already linked to this telegram identity (sub)  -> return it
2. a user with the same phone_number in the tenant        -> link identity, return it
3. otherwise                                              -> create user + identity

Telegram supplies the phone number (not an email), so phone_number is the key used to attach the login to an existing account.

Instance Method Summary collapse

Instance Method Details

#callObject

:id_token, :tenant_id (optional)



13
14
15
16
17
18
19
20
# File 'app/interactors/spree_cm_commissioner/user_telegram_oauth_authenticator.rb', line 13

def call
  context.fail!(message: 'telegram_id_token_missing') if id_token.blank?

  provider = verified_provider
  context.user = find_or_register_user(provider)

  reject_unauthenticatable_user!(context.user)
end