This repository has been archived by the owner on May 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplugin.rb
74 lines (54 loc) · 1.59 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# name: omniauth-mindvalley-discourse
# about: Authenticate with discourse with Mindvalley
# version: 0.1.0
# author: parasquid
gem 'omniauth-mindvalley'
class MindvalleyAuthenticator < ::Auth::Authenticator
CLIENT_ID = '1111111'
CLIENT_SECRET = 'AUSTRALIASNAKESALAD'
def name
'mindvalley'
end
def after_authenticate(auth_token)
result = Auth::Result.new
# grap the info we need from omni auth
data = auth_token[:info]
name = data["first_name"]
mv_uid = auth_token["uid"]
email = data['email']
# plugin specific data storage
current_info = ::PluginStore.get("mv", "mv_uid_#{mv_uid}")
result.user =
if current_info
User.where(id: current_info[:user_id]).first
end
result.name = name
result.extra_data = { mv_uid: mv_uid }
result.email = email
result
end
def after_create_account(user, auth)
data = auth[:extra_data]
::PluginStore.set("mv", "mv_uid_#{data[:mv_uid]}", {user_id: user.id })
end
def register_middleware(omniauth)
omniauth.provider :mindvalley,
CLIENT_ID,
CLIENT_SECRET
end
end
auth_provider :title => 'with Mindvalley Accounts',
:message => 'Log in via Mindvalley Accounts (Make sure pop up blockers are not enabled).',
:frame_width => 920,
:frame_height => 800,
:authenticator => MindvalleyAuthenticator.new
# We ship with zocial, it may have an icon you like http://zocial.smcllns.com/sample.html
# in our current case we have an icon for vk
register_css <<CSS
.btn-social.vkontakte {
background: #46698f;
}
.btn-social.vkontakte:before {
content: "N";
}
CSS