Class: OmniAuth::Strategies::Telegram

Inherits:
Object
  • Object
show all
Includes:
OmniAuth::Strategy
Defined in:
lib/omniauth/strategies/telegram.rb

Constant Summary collapse

REQUIRED_FIELDS =
%w[id hash]
HASH_FIELDS =
%w[auth_date first_name id last_name photo_url username]

Instance Method Summary collapse

Instance Method Details

#callback_phaseObject



47
48
49
50
51
52
53
# File 'lib/omniauth/strategies/telegram.rb', line 47

def callback_phase
  if error = check_errors
    fail!(error)
  else
    super
  end
end

#request_phaseObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/omniauth/strategies/telegram.rb', line 20

def request_phase
  html = "    <!DOCTYPE html>\n    <html>\n    <head>\n      <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n      <title>Telegram Login</title>\n    </head>\n    <body>\n  HTML\n\n  data_attrs = options.button_config.map { |k,v| \"data-\#{k}=\\\"\#{v}\\\"\" }.join(\" \")\n\n  html << \"<script async\n        src=\\\"https://telegram.org/js/telegram-widget.js?4\\\"\n        data-telegram-login=\\\"\#{options.bot_name}\\\"\n        data-auth-url=\\\"\#{callback_url}\\\"\n  \#{data_attrs}></script>\"\n\n  html << <<-HTML\n    </body>\n    </html>\n  HTML\n\n  Rack::Response.new(html, 200, 'content-type' => 'text/html').finish\nend\n"