forked from mjsir911/discourse-telegram-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.rb
More file actions
38 lines (29 loc) · 1 KB
/
Copy pathplugin.rb
File metadata and controls
38 lines (29 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true
# name: discourse-telegram-auth
# about: Enable Login via Telegram
# version: 1.0
# authors: Marco Sirabella
# url: https://github.com/mjsir911/discourse-telegram-auth
gem 'omniauth-telegram', '0.2.1', require: false
enabled_site_setting :telegram_auth_enabled
register_svg_icon "fab-telegram"
extend_content_security_policy script_src: ['https://telegram.org/js/telegram-widget.js']
require "omniauth/telegram"
class ::TelegramAuthenticator < ::Auth::ManagedAuthenticator
def name
"telegram"
end
def enabled?
SiteSetting.telegram_auth_enabled
end
def register_middleware(omniauth)
omniauth.provider :telegram,
setup: lambda { |env|
strategy = env["omniauth.strategy"]
strategy.options[:bot_name] = SiteSetting.telegram_auth_bot_name
strategy.options[:bot_secret] = SiteSetting.telegram_auth_bot_token
}
end
end
auth_provider authenticator: ::TelegramAuthenticator.new,
icon: "fab-telegram"