-
Notifications
You must be signed in to change notification settings - Fork 3
/
plugin.rb
39 lines (30 loc) · 950 Bytes
/
plugin.rb
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
39
# frozen_string_literal: true
# name: discourse-wikimedia-auth
# about: Enable Login via Wikimedia
# version: 0.1.3
# authors: Angus McLeod
# url: https://github.com/paviliondev/discourse-wikimedia-auth
# contact_emails: [email protected]
gem 'omniauth-mediawiki', '0.0.4'
enabled_site_setting :wikimedia_auth_enabled
register_asset 'stylesheets/common/wikimedia.scss'
%w(
../lib/auth/wikimedia_authenticator.rb
../lib/wikimedia_username.rb
).each do |path|
load File.expand_path(path, __FILE__)
end
auth_provider authenticator: Auth::WikimediaAuthenticator.new
after_initialize do
%w(
../extensions/guardian.rb
).each do |path|
load File.expand_path(path, __FILE__)
end
::Guardian.prepend GuardianWikimediaExtension
add_to_serializer(:user, :wiki_username) do
UserAssociatedAccount.where(user_id: object.id)
.select("info::json->>'nickname' as wiki_username")
.first&.wiki_username
end
end