1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @package Social Login |
5
|
|
|
* @author Iurii Makukh |
6
|
|
|
* @copyright Copyright (c) 2017, Iurii Makukh |
7
|
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.en.html GPL-3.0+ |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace gplcart\modules\social_login; |
11
|
|
|
|
12
|
|
|
use gplcart\core\Module as CoreModule; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Main class for Social Login module |
16
|
|
|
*/ |
17
|
|
|
class Module |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Module class instance |
22
|
|
|
* @var \gplcart\core\Module $module |
23
|
|
|
*/ |
24
|
|
|
protected $module; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param CoreModule $module |
28
|
|
|
*/ |
29
|
|
|
public function __construct(CoreModule $module) |
30
|
|
|
{ |
31
|
|
|
$this->module = $module; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Implements hook "route.list" |
36
|
|
|
* @param array $routes |
37
|
|
|
*/ |
38
|
|
|
public function hookRouteList(array &$routes) |
39
|
|
|
{ |
40
|
|
|
$routes['admin/module/settings/social_login'] = array( |
41
|
|
|
'access' => 'module_edit', |
42
|
|
|
'handlers' => array( |
43
|
|
|
'controller' => array('gplcart\\modules\\social_login\\controllers\\Settings', 'editSettings') |
44
|
|
|
) |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Implements hook "oauth.providers" |
50
|
|
|
* @param array $providers |
51
|
|
|
*/ |
52
|
|
|
public function hookOauthProviders(array &$providers) |
53
|
|
|
{ |
54
|
|
|
$settings = $this->module->getSettings('social_login'); |
55
|
|
|
|
56
|
|
|
$providers['facebook'] = array( |
57
|
|
|
'name' => 'Facebook', |
58
|
|
|
'status' => !empty($settings['status']['facebook']), |
59
|
|
|
'type' => 'login', |
60
|
|
|
'scope' => 'email', |
61
|
|
|
'url' => array( |
62
|
|
|
'auth' => 'https://www.facebook.com/v2.8/dialog/oauth', |
63
|
|
|
'token' => 'https://graph.facebook.com/v2.8/oauth/access_token' |
64
|
|
|
), |
65
|
|
|
'settings' => array( |
66
|
|
|
'register' => $settings['register'], |
67
|
|
|
'register_login' => $settings['register_login'], |
68
|
|
|
'register_status' => $settings['register_status'], |
69
|
|
|
'client_id' => isset($settings['client_id']['facebook']) ? $settings['client_id']['facebook'] : '', |
70
|
|
|
'client_secret' => isset($settings['client_secret']['facebook']) ? $settings['client_secret']['facebook'] : '', |
71
|
|
|
), |
72
|
|
|
'template' => array('button' => 'social_login|buttons/facebook'), |
73
|
|
|
'handlers' => array( |
74
|
|
|
'process' => array('gplcart\\modules\\social_login\\handlers\\Facebook', 'process'), |
75
|
|
|
) |
76
|
|
|
); |
77
|
|
|
|
78
|
|
|
$providers['google'] = array( |
79
|
|
|
'name' => 'Google+', |
80
|
|
|
'type' => 'login', |
81
|
|
|
'scope' => 'email', |
82
|
|
|
'status' => !empty($settings['status']['google']), |
83
|
|
|
'url' => array( |
84
|
|
|
'auth' => 'https://accounts.google.com/o/oauth2/auth', |
85
|
|
|
'token' => 'https://accounts.google.com/o/oauth2/token' |
86
|
|
|
), |
87
|
|
|
'settings' => array( |
88
|
|
|
'register' => $settings['register'], |
89
|
|
|
'register_login' => $settings['register_login'], |
90
|
|
|
'register_status' => $settings['register_status'], |
91
|
|
|
'client_id' => isset($settings['client_id']['google']) ? $settings['client_id']['google'] : '', |
92
|
|
|
'client_secret' => isset($settings['client_secret']['google']) ? $settings['client_secret']['google'] : '', |
93
|
|
|
), |
94
|
|
|
'template' => array('button' => 'social_login|buttons/google'), |
95
|
|
|
'handlers' => array( |
96
|
|
|
'process' => array('gplcart\\modules\\social_login\\handlers\\Google', 'process'), |
97
|
|
|
) |
98
|
|
|
); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
} |
102
|
|
|
|