WordPress Social Login - Version 2.2.1

Version Description

  • WSL can be fully integrated with your BuddyPress installation: display of users avatars and xprofiles mapping.
  • WSL is now updated to work with the latest apis changes of the supported social networks.
  • WSL Widget is now more flexible than before and can be fully customized to fit you website theme.
  • Introducing new providers : Reddit, Disqus and PixelPin.
  • WSL Hooks has been reworked and few hooks have been depreciated in favour of new ones. For more information, see: http://hybridauth.sourceforge.net/wsl/developer.html
  • A number of bugfixes, small enhancements and visual updates.
Download this release

Release Info

Developer miled
Plugin Icon 128x128 WordPress Social Login
Version 2.2.1
Comparing to
See all releases

Code changes from version 2.1.6 to 2.2.1

Files changed (167) hide show
  1. assets/css/style.css +11 -13
  2. assets/img/16x16/500px.png +0 -0
  3. assets/img/16x16/disqus.png +0 -0
  4. assets/img/16x16/dribbble.png +0 -0
  5. assets/img/16x16/flickr.png +0 -0
  6. assets/img/16x16/github.png +0 -0
  7. assets/img/16x16/hyves.png +0 -0
  8. assets/img/16x16/instagram.png +0 -0
  9. assets/img/16x16/latch.png +0 -0
  10. assets/img/16x16/livejournal.png +0 -0
  11. assets/img/16x16/mailru.png +0 -0
  12. assets/img/16x16/mixi.png +0 -0
  13. assets/img/16x16/mixx.png +0 -0
  14. assets/img/16x16/myspace.png +0 -0
  15. assets/img/16x16/odnoklassniki.png +0 -0
  16. assets/img/16x16/{openid-2.png → openid.png} +0 -0
  17. assets/img/16x16/orkut.png +0 -0
  18. assets/img/16x16/pixelpin.png +0 -0
  19. assets/img/16x16/{flickr-2.png → reddit.png} +0 -0
  20. assets/img/16x16/stackoverflow.png +0 -0
  21. assets/img/16x16/steam.png +0 -0
  22. assets/img/16x16/twitchtv.png +0 -0
  23. assets/img/16x16/vkontakte.png +0 -0
  24. assets/img/16x16/wordpress.png +0 -0
  25. assets/img/16x16/yandex.png +0 -0
  26. assets/img/32x32/icondock/disqus.png +0 -0
  27. assets/img/32x32/icondock/gowalla.png +0 -0
  28. assets/img/32x32/icondock/info.txt +6 -2
  29. assets/img/32x32/icondock/latch.png +0 -0
  30. assets/img/32x32/icondock/myspace.png +0 -0
  31. assets/img/32x32/icondock/paypal.png +0 -0
  32. assets/img/32x32/icondock/pixelpin.png +0 -0
  33. assets/img/32x32/icondock/reddit.png +0 -0
  34. assets/img/32x32/wpzoom/disqus.png +0 -0
  35. assets/img/32x32/wpzoom/gowalla.png +0 -0
  36. assets/img/32x32/wpzoom/latch.png +0 -0
  37. assets/img/32x32/wpzoom/myspace.png +0 -0
  38. assets/img/32x32/wpzoom/{openid-2.png → openid.png} +0 -0
  39. assets/img/32x32/wpzoom/paypal.png +0 -0
  40. assets/img/32x32/wpzoom/pixelpin.png +0 -0
  41. assets/img/32x32/wpzoom/reddit.png +0 -0
  42. assets/img/alert.png +0 -0
  43. assets/img/arr_right.png +0 -0
  44. assets/js/connect.js +0 -49
  45. assets/js/script.js +64 -0
  46. hybridauth/Hybrid/Auth.php +15 -20
  47. hybridauth/Hybrid/Endpoint.php +16 -17
  48. hybridauth/Hybrid/Error.php +11 -6
  49. hybridauth/Hybrid/Exception.php +16 -0
  50. hybridauth/Hybrid/Logger.php +37 -13
  51. hybridauth/Hybrid/Provider_Adapter.php +61 -22
  52. hybridauth/Hybrid/Provider_Model.php +47 -15
  53. hybridauth/Hybrid/Provider_Model_OAuth1.php +20 -10
  54. hybridauth/Hybrid/Provider_Model_OAuth2.php +15 -7
  55. hybridauth/Hybrid/Provider_Model_OpenID.php +44 -37
  56. hybridauth/Hybrid/Providers/Disqus.php +59 -0
  57. hybridauth/Hybrid/Providers/Facebook.php +201 -37
  58. hybridauth/Hybrid/Providers/Foursquare.php +1 -1
  59. hybridauth/Hybrid/Providers/GitHub.php +17 -1
  60. hybridauth/Hybrid/Providers/Goodreads.php +7 -7
  61. hybridauth/Hybrid/Providers/Google.php +197 -33
  62. hybridauth/Hybrid/Providers/Gowalla.php +0 -102
  63. hybridauth/Hybrid/Providers/Identica.php +1 -1
  64. hybridauth/Hybrid/Providers/Instagram.php +48 -48
  65. hybridauth/Hybrid/Providers/LastFM.php +3 -3
  66. hybridauth/Hybrid/Providers/Latch.php +30 -0
  67. hybridauth/Hybrid/Providers/LinkedIn.php +5 -2
  68. hybridauth/Hybrid/Providers/Live.php +2 -2
  69. hybridauth/Hybrid/Providers/Mailru.php +1 -1
  70. hybridauth/Hybrid/Providers/MySpace.php +0 -164
  71. hybridauth/Hybrid/Providers/Odnoklassniki.php +23 -16
  72. hybridauth/Hybrid/Providers/Paypal.php +146 -0
  73. hybridauth/Hybrid/Providers/PixelPin.php +49 -0
  74. hybridauth/Hybrid/Providers/Reddit.php +205 -0
  75. hybridauth/Hybrid/Providers/Steam.php +15 -19
  76. hybridauth/Hybrid/Providers/Twitter.php +118 -13
  77. hybridauth/Hybrid/Providers/Vkontakte.php +44 -8
  78. hybridauth/Hybrid/Providers/Yahoo.php +11 -11
  79. hybridauth/Hybrid/Providers/Yandex.php +3 -3
  80. hybridauth/Hybrid/Storage.php +61 -18
  81. hybridauth/Hybrid/StorageInterface.php +28 -0
  82. hybridauth/Hybrid/User.php +16 -7
  83. hybridauth/Hybrid/User_Activity.php +22 -7
  84. hybridauth/Hybrid/User_Contact.php +32 -11
  85. hybridauth/Hybrid/User_Profile.php +125 -59
  86. hybridauth/Hybrid/resources/config.php.tpl +72 -0
  87. hybridauth/Hybrid/thirdparty/Facebook/base_facebook.php +171 -61
  88. hybridauth/Hybrid/thirdparty/Facebook/facebook.php +76 -8
  89. hybridauth/Hybrid/thirdparty/LinkedIn/LinkedIn.php +16 -7
  90. hybridauth/Hybrid/thirdparty/OAuth/OAuth.php +20 -16
  91. hybridauth/Hybrid/thirdparty/OAuth/OAuth1Client.php +40 -16
  92. hybridauth/Hybrid/thirdparty/OAuth/OAuth2Client.php +22 -11
  93. hybridauth/Hybrid/thirdparty/OpenID/LightOpenID.php +984 -834
  94. hybridauth/Hybrid/thirdparty/Paypal/PaypalOAuth2Client.php +142 -0
  95. hybridauth/changes.txt +26 -0
  96. hybridauth/readme.txt +2 -11
  97. includes/admin/components/advanced/index.php +0 -111
  98. includes/admin/components/bouncer/index.php +1 -3
  99. includes/admin/components/bouncer/wsl.components.bouncer.setup.php +33 -25
  100. includes/admin/components/bouncer/wsl.components.bouncer.sidebar.php +5 -5
  101. includes/admin/components/buddypress/index.php +60 -0
  102. includes/admin/components/buddypress/wsl.components.buddypress.notfound.php +59 -0
  103. includes/admin/components/buddypress/wsl.components.buddypress.setup.php +256 -0
  104. includes/admin/components/buddypress/wsl.components.buddypress.sidebar.php +50 -0
  105. includes/admin/components/components/index.php +1 -1
  106. includes/admin/components/components/wsl.components.help.gallery.php +3 -15
  107. includes/admin/components/components/wsl.components.help.setup.php +37 -10
  108. includes/admin/components/contacts/index.php +136 -116
  109. includes/admin/components/diagnostics/index.php +60 -43
  110. includes/admin/components/help/index.php +56 -6
  111. includes/admin/components/login-widget/index.php +1 -3
  112. includes/admin/components/login-widget/wsl.components.loginwidget.setup.php +109 -38
  113. includes/admin/components/login-widget/wsl.components.loginwidget.sidebar.php +14 -10
  114. includes/admin/components/networks/index.php +1 -1
  115. includes/admin/components/networks/wsl.components.networks.addmore.php +4 -5
  116. includes/admin/components/networks/wsl.components.networks.basicinsights.php +69 -110
  117. includes/admin/components/networks/wsl.components.networks.setup.php +135 -101
  118. includes/admin/components/networks/wsl.components.networks.whyhello.php +12 -13
  119. includes/admin/components/users/index.php +1 -1
  120. includes/admin/components/users/wsl.components.users.list.php +149 -84
  121. includes/admin/components/users/wsl.components.users.profile.php +109 -40
  122. includes/admin/components/watchdog/index.php +214 -0
  123. includes/admin/wsl.admin.ui.php +105 -250
  124. includes/services/wsl.authentication.php +660 -734
  125. includes/services/wsl.mail.notification.php +4 -3
  126. includes/services/wsl.user.avatar.php +106 -39
  127. includes/services/wsl.user.data.php +238 -128
  128. includes/services/wsl.utilities.php +385 -0
  129. includes/settings/wsl.compatibilities.php +34 -86
  130. includes/settings/wsl.database.php +45 -42
  131. includes/settings/wsl.initialization.php +60 -209
  132. includes/settings/wsl.providers.php +76 -46
  133. includes/widgets/wsl.auth.widget.php +169 -315
  134. includes/widgets/wsl.complete.registration.php +71 -73
  135. includes/widgets/wsl.error.pages.php +285 -0
  136. includes/widgets/wsl.loading.screens.php +200 -0
  137. includes/widgets/wsl.notices.php +0 -67
  138. languages/readme.txt +6 -0
  139. languages/wordpress-social-login-ar.mo +0 -0
  140. languages/wordpress-social-login-ar.po +0 -1446
  141. languages/wordpress-social-login-de_DE.mo +0 -0
  142. languages/wordpress-social-login-de_DE.po +0 -1449
  143. languages/wordpress-social-login-es_ES.mo +0 -0
  144. languages/wordpress-social-login-es_ES.po +0 -1446
  145. languages/wordpress-social-login-fr_FR.mo +0 -0
  146. languages/wordpress-social-login-fr_FR.po +0 -1446
  147. languages/wordpress-social-login-he_IL.mo +0 -0
  148. languages/wordpress-social-login-he_IL.po +0 -1446
  149. languages/wordpress-social-login-ja.mo +0 -0
  150. languages/wordpress-social-login-ja.po +0 -1446
  151. languages/wordpress-social-login-ru_RU.mo +0 -0
  152. languages/wordpress-social-login-ru_RU.po +0 -1446
  153. languages/wordpress-social-login-zh_CN.mo +0 -0
  154. languages/wordpress-social-login-zh_CN.po +0 -1446
  155. readme.txt +42 -37
  156. screenshot-1.png +0 -0
  157. screenshot-2.png +0 -0
  158. screenshot-3.png +0 -0
  159. screenshot-4.png +0 -0
  160. services/diagnostics.php +0 -168
  161. services/index.php +0 -2
  162. uninstall.php +88 -0
  163. utilities/diagnostics.php +190 -0
  164. utilities/index.php +4 -0
  165. {services → utilities}/siteinfo.php +8 -11
  166. utilities/watchdog.php +206 -0
  167. wp-social-login.php +92 -149
assets/css/style.css CHANGED
@@ -1,15 +1,13 @@
1
- #wp-social-login-connect-with{
2
- font-weight: bold;
3
- }
4
5
- #wp-social-login-connect-options{
6
- padding:10px;
7
- }
8
9
- #wp-social-login-connect-options a{
10
- text-decoration: none;
11
- }
12
-
13
- #wp-social-login-connect-options img{
14
- border:0 none;
15
- }
1
+ /*
2
+ ! Notes:
3
+ ! Since WSL 2.2.1, all elements IDs generated by the widget are replaced by css classes :
4
+ ! #wp-social-login-connect-with replaced with .wp-social-login-connect-with
5
+ ! #wp-social-login-connect-options replaced with .wp-social-login-provider-list
6
7
+ ! Class .wsl_connect_with_provider will be replaced with .wp-social-login-provider .wp-social-login-provider-{provider}
8
9
+ ! Those depreciated selectors are kept for backward compatibility and will be removed.
10
+ */
11
+ .wp-social-login-provider-list { padding: 10px; }
12
+ .wp-social-login-provider-list a {text-decoration: none; }
13
+ .wp-social-login-provider-list img{ border: 0 none; }
assets/img/16x16/500px.png CHANGED
Binary file
assets/img/16x16/disqus.png ADDED
Binary file
assets/img/16x16/dribbble.png DELETED
Binary file
assets/img/16x16/flickr.png CHANGED
Binary file
assets/img/16x16/github.png CHANGED
Binary file
assets/img/16x16/hyves.png CHANGED
Binary file
assets/img/16x16/instagram.png CHANGED
Binary file
assets/img/16x16/latch.png ADDED
Binary file
assets/img/16x16/livejournal.png DELETED
Binary file
assets/img/16x16/mailru.png CHANGED
Binary file
assets/img/16x16/mixi.png CHANGED
Binary file
assets/img/16x16/mixx.png DELETED
Binary file
assets/img/16x16/myspace.png DELETED
Binary file
assets/img/16x16/odnoklassniki.png CHANGED
Binary file
assets/img/16x16/{openid-2.png → openid.png} RENAMED
File without changes
assets/img/16x16/orkut.png DELETED
Binary file
assets/img/16x16/pixelpin.png ADDED
Binary file
assets/img/16x16/{flickr-2.png → reddit.png} RENAMED
Binary file
assets/img/16x16/stackoverflow.png CHANGED
Binary file
assets/img/16x16/steam.png CHANGED
Binary file
assets/img/16x16/twitchtv.png CHANGED
Binary file
assets/img/16x16/vkontakte.png CHANGED
Binary file
assets/img/16x16/wordpress.png CHANGED
Binary file
assets/img/16x16/yandex.png CHANGED
Binary file
assets/img/32x32/icondock/disqus.png ADDED
Binary file
assets/img/32x32/icondock/gowalla.png DELETED
Binary file
assets/img/32x32/icondock/info.txt CHANGED
@@ -1,6 +1,10 @@
1
Vector Social Media Icons
2
- by IconDock.com & Double-J Design (http://www.doublejdesign.co.uk)
3
4
URL: http://icondock.com/free/vector-social-media-icons
5
6
- Note: the company logos in the icons are copyright of their respective owners.
1
Vector Social Media Icons
2
+ by IconDock.com
3
4
URL: http://icondock.com/free/vector-social-media-icons
5
6
+ Note: the company logos in the icons are copyright of their respective owners.
7
+
8
+ From http://icondock.com/free/vector-social-media-icons
9
+ "Free to use for whatever purposes. If you use these icons, an optional link to
10
+ http://icondock.com would be appreciated. Thank you."
assets/img/32x32/icondock/latch.png ADDED
Binary file
assets/img/32x32/icondock/myspace.png DELETED
Binary file
assets/img/32x32/icondock/paypal.png ADDED
Binary file
assets/img/32x32/icondock/pixelpin.png ADDED
Binary file
assets/img/32x32/icondock/reddit.png ADDED
Binary file
assets/img/32x32/wpzoom/disqus.png ADDED
Binary file
assets/img/32x32/wpzoom/gowalla.png DELETED
Binary file
assets/img/32x32/wpzoom/latch.png ADDED
Binary file
assets/img/32x32/wpzoom/myspace.png DELETED
Binary file
assets/img/32x32/wpzoom/{openid-2.png → openid.png} RENAMED
File without changes
assets/img/32x32/wpzoom/paypal.png ADDED
Binary file
assets/img/32x32/wpzoom/pixelpin.png ADDED
Binary file
assets/img/32x32/wpzoom/reddit.png ADDED
Binary file
assets/img/alert.png CHANGED
Binary file
assets/img/arr_right.png ADDED
Binary file
assets/js/connect.js DELETED
@@ -1,49 +0,0 @@
1
- /* Based on http://wordpress.org/extend/plugins/social-connect/ */
2
-
3
- (function($){
4
- $(function(){
5
- $(".wsl_connect_with_provider").click(function(){
6
- popupurl = $("#wsl_popup_base_url").val();
7
- provider = $(this).attr("data-provider");
8
-
9
- window.open(
10
- popupurl+"provider="+provider,
11
- "hybridauth_social_sing_on",
12
- "location=1,status=0,scrollbars=0,width=1000,height=600"
13
- );
14
- });
15
- });
16
- })(jQuery);
17
-
18
- window.wsl_wordpress_social_login = function(config) {
19
- jQuery('#loginform').unbind('submit.simplemodal-login');
20
-
21
- var form_id = '#loginform';
22
-
23
- if(!jQuery('#loginform').length) {
24
- // if register form exists, just use that
25
- if( jQuery('#registerform').length ) {
26
- form_id = '#registerform';
27
- }
28
- else {
29
- // create the login form
30
- var login_uri = jQuery("#wsl_login_form_uri").val();
31
-
32
- jQuery('body').append("<form id='loginform' method='post' action='" + login_uri + "'></form>");
33
- jQuery('#loginform').append("<input type='hidden' id='redirect_to' name='redirect_to' value='" + window.location.href + "'>");
34
- }
35
- }
36
-
37
- jQuery.each(config, function(key, value) {
38
- jQuery("#" + key).remove();
39
- jQuery(form_id).append("<input type='hidden' id='" + key + "' name='" + key + "' value='" + value + "'>");
40
- });
41
-
42
- if(jQuery("#simplemodal-login-form").length) {
43
- var current_url = window.location.href;
44
- jQuery("#redirect_to").remove();
45
- jQuery(form_id).append("<input type='hidden' id='redirect_to' name='redirect_to' value='" + current_url + "'>");
46
- }
47
-
48
- jQuery(form_id).submit();
49
- }
assets/js/script.js ADDED
@@ -0,0 +1,64 @@
1
+ /*!
2
+ * WordPress Social Login
3
+ *
4
+ * http://hybridauth.sourceforge.net/wsl/index.html | http://github.com/hybridauth/WordPress-Social-Login
5
+ * (c) 2011-2014 Mohamed Mrassi and contributors | http://wordpress.org/extend/plugins/wordpress-social-login/
6
+ */
7
+
8
+ /**
9
+ * Manage authentications via a popup
10
+ *
11
+ * Based on http://wordpress.org/extend/plugins/social-connect/
12
+ */
13
+
14
+ (function($){
15
+ $(function(){
16
+ //
17
+ $(document).on("click", "a.wsl_connect_with_provider", function(){
18
+ popupurl = $("#wsl_popup_base_url").val();
19
+ provider = $(this).attr("data-provider");
20
+
21
+ window.open( popupurl + "provider=" + provider, "hybridauth_social_sing_on", "location=1,status=0,scrollbars=0,width=1000,height=600" );
22
+ });
23
+ });
24
+ })(jQuery);
25
+
26
+ /**
27
+ *
28
+ */
29
+ window.wsl_wordpress_social_login = function(config){
30
+ jQuery('#loginform').unbind('submit.simplemodal-login');
31
+
32
+ var form_id = '#loginform';
33
+
34
+ if( ! jQuery('#loginform').length ){
35
+ // if register form exists, just use that
36
+ if( jQuery('#registerform').length ){
37
+ form_id = '#registerform';
38
+ }
39
+
40
+ // create the login form
41
+ else {
42
+ var login_uri = jQuery("#wsl_login_form_uri").val();
43
+
44
+ jQuery('body').append( "<form id='loginform' method='post' action='" + login_uri + "'></form>" );
45
+ jQuery('#loginform').append( "<input type='hidden' id='redirect_to' name='redirect_to' value='" + window.location.href + "'>" );
46
+ }
47
+ }
48
+
49
+ jQuery.each(config, function(key, value){
50
+ jQuery("#" + key).remove();
51
+
52
+ jQuery(form_id).append( "<input type='hidden' id='" + key + "' name='" + key + "' value='" + value + "'>" );
53
+ });
54
+
55
+ if( jQuery("#simplemodal-login-form").length ){
56
+ var current_url = window.location.href;
57
+
58
+ jQuery("#redirect_to").remove();
59
+
60
+ jQuery(form_id).append( "<input type='hidden' id='redirect_to' name='redirect_to' value='" + current_url + "'>" );
61
+ }
62
+
63
+ jQuery(form_id).submit();
64
+ }
hybridauth/Hybrid/Auth.php CHANGED
@@ -1,8 +1,8 @@
1
<?php
2
- /*!
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
- * (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
@@ -14,7 +14,7 @@
14
*/
15
class Hybrid_Auth
16
{
17
- public static $version = "2.1.1-dev";
18
19
public static $config = array();
20
@@ -68,10 +68,9 @@ class Hybrid_Auth
68
69
# load hybridauth required files, a autoload is on the way...
70
require_once $config["path_base"] . "Error.php";
71
require_once $config["path_base"] . "Logger.php";
72
73
- require_once $config["path_base"] . "Storage.php";
74
-
75
require_once $config["path_base"] . "Provider_Adapter.php";
76
77
require_once $config["path_base"] . "Provider_Model.php";
@@ -84,13 +83,17 @@ class Hybrid_Auth
84
require_once $config["path_base"] . "User_Contact.php";
85
require_once $config["path_base"] . "User_Activity.php";
86
87
// hash given config
88
Hybrid_Auth::$config = $config;
89
90
- // instace of log mng
91
Hybrid_Auth::$logger = new Hybrid_Logger();
92
93
- // instace of errors mng
94
Hybrid_Auth::$error = new Hybrid_Error();
95
96
// start session storage mng
@@ -161,7 +164,7 @@ class Hybrid_Auth
161
/**
162
* Hybrid storage system accessor
163
*
164
- * Users sessions are stored using HybridAuth storage system ( HybridAuth 2.0 handle PHP Session only) and can be acessed directly by
165
* Hybrid_Auth::storage()->get($key) to retrieves the data for the given key, or calling
166
* Hybrid_Auth::storage()->set($key, $value) to store the key => $value set.
167
*/
@@ -249,7 +252,7 @@ class Hybrid_Auth
249
if( ! $params ){
250
$params = Hybrid_Auth::storage()->get( "hauth_session.$providerId.id_provider_params" );
251
252
- Hybrid_Logger::debug( "Hybrid_Auth::setup( $providerId ), no params given. Trying to get the sotred for this provider.", $params );
253
}
254
255
if( ! $params ){
@@ -258,11 +261,11 @@ class Hybrid_Auth
258
Hybrid_Logger::info( "Hybrid_Auth::setup( $providerId ), no stored params found for this provider. Initialize a new one for new session" );
259
}
260
261
- if( ! isset( $params["hauth_return_to"] ) ){
262
$params["hauth_return_to"] = Hybrid_Auth::getCurrentUrl();
263
- }
264
265
- Hybrid_Logger::debug( "Hybrid_Auth::setup( $providerId ). HybridAuth Callback URL set to: ", $params["hauth_return_to"] );
266
267
# instantiate a new IDProvider Adapter
268
$provider = new Hybrid_Provider_Adapter();
@@ -385,14 +388,6 @@ class Hybrid_Auth
385
386
$url = $protocol . $_SERVER['HTTP_HOST'];
387
388
- // use port if non default
389
- if( isset( $_SERVER['SERVER_PORT'] ) && strpos( $url, ':'.$_SERVER['SERVER_PORT'] ) === FALSE ) {
390
- $url .= ($protocol === 'http://' && $_SERVER['SERVER_PORT'] != 80 && !isset( $_SERVER['HTTP_X_FORWARDED_PROTO']))
391
- || ($protocol === 'https://' && $_SERVER['SERVER_PORT'] != 443 && !isset( $_SERVER['HTTP_X_FORWARDED_PROTO']))
392
- ? ':' . $_SERVER['SERVER_PORT']
393
- : '';
394
- }
395
-
396
if( $request_uri ){
397
$url .= $_SERVER['REQUEST_URI'];
398
}
1
<?php
2
+ /**
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
+ * (c) 2009-2014, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
14
*/
15
class Hybrid_Auth
16
{
17
+ public static $version = "2.3.0-dev";
18
19
public static $config = array();
20
68
69
# load hybridauth required files, a autoload is on the way...
70
require_once $config["path_base"] . "Error.php";
71
+ require_once $config["path_base"] . "Exception.php";
72
require_once $config["path_base"] . "Logger.php";
73
74
require_once $config["path_base"] . "Provider_Adapter.php";
75
76
require_once $config["path_base"] . "Provider_Model.php";
83
require_once $config["path_base"] . "User_Contact.php";
84
require_once $config["path_base"] . "User_Activity.php";
85
86
+ if ( ! class_exists("Hybrid_Storage", false) ){
87
+ require_once $config["path_base"] . "Storage.php";
88
+ }
89
+
90
// hash given config
91
Hybrid_Auth::$config = $config;
92
93
+ // instance of log mng
94
Hybrid_Auth::$logger = new Hybrid_Logger();
95
96
+ // instance of errors mng
97
Hybrid_Auth::$error = new Hybrid_Error();
98
99
// start session storage mng
164
/**
165
* Hybrid storage system accessor
166
*
167
+ * Users sessions are stored using HybridAuth storage system ( HybridAuth 2.0 handle PHP Session only) and can be accessed directly by
168
* Hybrid_Auth::storage()->get($key) to retrieves the data for the given key, or calling
169
* Hybrid_Auth::storage()->set($key, $value) to store the key => $value set.
170
*/
252
if( ! $params ){
253
$params = Hybrid_Auth::storage()->get( "hauth_session.$providerId.id_provider_params" );
254
255
+ Hybrid_Logger::debug( "Hybrid_Auth::setup( $providerId ), no params given. Trying to get the stored for this provider.", $params );
256
}
257
258
if( ! $params ){
261
Hybrid_Logger::info( "Hybrid_Auth::setup( $providerId ), no stored params found for this provider. Initialize a new one for new session" );
262
}
263
264
+ if( is_array($params) && ! isset( $params["hauth_return_to"] ) ){
265
$params["hauth_return_to"] = Hybrid_Auth::getCurrentUrl();
266
267
+ Hybrid_Logger::debug( "Hybrid_Auth::setup( $providerId ). HybridAuth Callback URL set to: ", $params["hauth_return_to"] );
268
+ }
269
270
# instantiate a new IDProvider Adapter
271
$provider = new Hybrid_Provider_Adapter();
388
389
$url = $protocol . $_SERVER['HTTP_HOST'];
390
391
if( $request_uri ){
392
$url .= $_SERVER['REQUEST_URI'];
393
}
hybridauth/Hybrid/Endpoint.php CHANGED
@@ -1,8 +1,8 @@
1
<?php
2
- /*!
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
- * (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
@@ -119,8 +119,7 @@ class Hybrid_Endpoint {
119
if( ! Hybrid_Auth::storage()->get( "hauth_session.$provider_id.hauth_endpoint" ) ) {
120
Hybrid_Logger::error( "Endpoint: hauth_endpoint parameter is not defined on hauth_start, halt login process!" );
121
122
- header( "HTTP/1.0 404 Not Found" );
123
- die( "You cannot access this page directly." );
124
}
125
126
# define:hybrid.endpoint.php step 2.
@@ -130,8 +129,7 @@ class Hybrid_Endpoint {
130
if( ! $hauth ) {
131
Hybrid_Logger::error( "Endpoint: Invalid parameter on hauth_start!" );
132
133
- header( "HTTP/1.0 404 Not Found" );
134
- die( "Invalid parameter! Please return to the login page and try again." );
135
}
136
137
try {
@@ -141,7 +139,7 @@ class Hybrid_Endpoint {
141
}
142
catch ( Exception $e ) {
143
Hybrid_Logger::error( "Exception:" . $e->getMessage(), $e );
144
- Hybrid_Error::setError( $e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e );
145
146
$hauth->returnToCallbackUrl();
147
}
@@ -165,8 +163,7 @@ class Hybrid_Endpoint {
165
166
$hauth->adapter->setUserUnconnected();
167
168
- header("HTTP/1.0 404 Not Found");
169
- die( "Invalid parameter! Please return to the login page and try again." );
170
}
171
172
try {
@@ -176,7 +173,7 @@ class Hybrid_Endpoint {
176
}
177
catch( Exception $e ){
178
Hybrid_Logger::error( "Exception:" . $e->getMessage(), $e );
179
- Hybrid_Error::setError( $e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e );
180
181
$hauth->adapter->setUserUnconnected();
182
}
@@ -194,23 +191,25 @@ class Hybrid_Endpoint {
194
195
# Init Hybrid_Auth
196
try {
197
- require_once realpath( dirname( __FILE__ ) ) . "/Storage.php";
198
199
$storage = new Hybrid_Storage();
200
201
// Check if Hybrid_Auth session already exist
202
- if ( ! $storage->config( "CONFIG" ) ) {
203
- header( "HTTP/1.0 404 Not Found" );
204
- die( "You cannot access this page directly." );
205
}
206
207
Hybrid_Auth::initialize( $storage->config( "CONFIG" ) );
208
}
209
catch ( Exception $e ){
210
- Hybrid_Logger::error( "Endpoint: Error while trying to init Hybrid_Auth" );
211
212
- header( "HTTP/1.0 404 Not Found" );
213
- die( "Oophs. Error!" );
214
}
215
}
216
}
1
<?php
2
+ /**
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
+ * (c) 2009-2014, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
119
if( ! Hybrid_Auth::storage()->get( "hauth_session.$provider_id.hauth_endpoint" ) ) {
120
Hybrid_Logger::error( "Endpoint: hauth_endpoint parameter is not defined on hauth_start, halt login process!" );
121
122
+ throw new Hybrid_Exception( "You cannot access this page directly." );
123
}
124
125
# define:hybrid.endpoint.php step 2.
129
if( ! $hauth ) {
130
Hybrid_Logger::error( "Endpoint: Invalid parameter on hauth_start!" );
131
132
+ throw new Hybrid_Exception( "Invalid parameter! Please return to the login page and try again." );
133
}
134
135
try {
139
}
140
catch ( Exception $e ) {
141
Hybrid_Logger::error( "Exception:" . $e->getMessage(), $e );
142
+ Hybrid_Error::setError( $e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e->getPrevious() );
143
144
$hauth->returnToCallbackUrl();
145
}
163
164
$hauth->adapter->setUserUnconnected();
165
166
+ throw new Hybrid_Exception( "Invalid parameter! Please return to the login page and try again." );
167
}
168
169
try {
173
}
174
catch( Exception $e ){
175
Hybrid_Logger::error( "Exception:" . $e->getMessage(), $e );
176
+ Hybrid_Error::setError( $e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e->getPrevious());
177
178
$hauth->adapter->setUserUnconnected();
179
}
191
192
# Init Hybrid_Auth
193
try {
194
+ if(!class_exists("Hybrid_Storage")){
195
+ require_once realpath( dirname( __FILE__ ) ) . "/Storage.php";
196
+ }
197
198
$storage = new Hybrid_Storage();
199
200
// Check if Hybrid_Auth session already exist
201
+ if ( ! $storage->config( "CONFIG" ) ) {
202
+ Hybrid_Logger::error( "Endpoint: Config storage not found when trying to init Hyrid_Auth. " );
203
+
204
+ throw new Hybrid_Exception( "You cannot access this page directly." );
205
}
206
207
Hybrid_Auth::initialize( $storage->config( "CONFIG" ) );
208
}
209
catch ( Exception $e ){
210
+ Hybrid_Logger::error( "Endpoint: Error while trying to init Hybrid_Auth: " . $e->getMessage());
211
212
+ throw new Hybrid_Exception( "Oophs. Error!" );
213
}
214
}
215
}
hybridauth/Hybrid/Error.php CHANGED
@@ -1,8 +1,8 @@
1
<?php
2
- /*!
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
- * (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
@@ -13,7 +13,12 @@
13
class Hybrid_Error
14
{
15
/**
16
- * store error in session
17
*/
18
public static function setError( $message, $code = NULL, $trace = NULL, $previous = NULL )
19
{
@@ -27,7 +32,7 @@ class Hybrid_Error
27
}
28
29
/**
30
- * clear the last error
31
*/
32
public static function clearError()
33
{
@@ -67,7 +72,7 @@ class Hybrid_Error
67
}
68
69
/**
70
- * return string detailled error backtrace as string.
71
*/
72
public static function getErrorTrace()
73
{
@@ -75,7 +80,7 @@ class Hybrid_Error
75
}
76
77
/**
78
- * @return string detailled error backtrace as string.
79
*/
80
public static function getErrorPrevious()
81
{
1
<?php
2
+ /**
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
+ * (c) 2009-2014, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
13
class Hybrid_Error
14
{
15
/**
16
+ * Store error in session
17
+ *
18
+ * @param String $message
19
+ * @param Number $code
20
+ * @param String $trace
21
+ * @param String $previous
22
*/
23
public static function setError( $message, $code = NULL, $trace = NULL, $previous = NULL )
24
{
32
}
33
34
/**
35
+ * Clear the last error
36
*/
37
public static function clearError()
38
{
72
}
73
74
/**
75
+ * return string detailed error backtrace as string.
76
*/
77
public static function getErrorTrace()
78
{
80
}
81
82
/**
83
+ * @return string detailed error backtrace as string.
84
*/
85
public static function getErrorPrevious()
86
{
hybridauth/Hybrid/Exception.php ADDED
@@ -0,0 +1,16 @@
1
+ <?php
2
+ /*!
3
+ * HybridAuth
4
+ * http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
+ * (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
+ */
7
+
8
+ /**
9
+ * Exception implementation
10
+ *
11
+ * The base Exception is extended to allow applications to handle exceptions from hybrid auth
12
+ * separately from general exceptions.
13
+ */
14
+ class Hybrid_Exception extends Exception
15
+ {
16
+ }
hybridauth/Hybrid/Logger.php CHANGED
@@ -1,8 +1,8 @@
1
<?php
2
- /*!
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
- * (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
@@ -10,20 +10,35 @@
10
*/
11
class Hybrid_Logger
12
{
13
function __construct()
14
{
15
- // if debug mode is set to true, then check for the writable log file
16
- if ( Hybrid_Auth::$config["debug_mode"] ){
17
- if ( ! file_exists( Hybrid_Auth::$config["debug_file"] ) ){
18
- throw new Exception( "'debug_mode' is set to 'true', but the file " . Hybrid_Auth::$config['debug_file'] . " in 'debug_file' does not exit.", 1 );
19
- }
20
21
- if ( ! is_writable( Hybrid_Auth::$config["debug_file"] ) ){
22
throw new Exception( "'debug_mode' is set to 'true', but the given log file path 'debug_file' is not a writable file.", 1 );
23
}
24
}
25
}
26
-
27
public static function debug( $message, $object = NULL )
28
{
29
if( Hybrid_Auth::$config["debug_mode"] ){
@@ -37,10 +52,14 @@ class Hybrid_Logger
37
);
38
}
39
}
40
-
41
public static function info( $message )
42
{
43
- if( Hybrid_Auth::$config["debug_mode"] ){
44
$datetime = new DateTime();
45
$datetime = $datetime->format(DATE_ATOM);
46
@@ -51,10 +70,15 @@ class Hybrid_Logger
51
);
52
}
53
}
54
-
55
public static function error($message, $object = NULL)
56
{
57
- if( Hybrid_Auth::$config["debug_mode"] ){
58
$datetime = new DateTime();
59
$datetime = $datetime->format(DATE_ATOM);
60
1
<?php
2
+ /**
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
+ * (c) 2009-2014, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
10
*/
11
class Hybrid_Logger
12
{
13
+ /**
14
+ * Constructor
15
+ */
16
function __construct()
17
{
18
+ // Hybrid_Auth::$config["debug_mode"] = true;
19
+ // Hybrid_Auth::$config["debug_file"] = 'C:/xampp/htdocs/hybridauth/hawp4/wp-content/plugins/wordpress-social-login/log/log.log';
20
21
+ // if debug mode is set to true, then check for the writable log file
22
+ if ( Hybrid_Auth::$config["debug_mode"] ){
23
+ if ( ! isset(Hybrid_Auth::$config["debug_file"]) ) {
24
+ throw new Exception( "'debug_mode' is set to 'true' but no log file path 'debug_file' is set.", 1 );
25
+ }
26
+ elseif ( ! file_exists( Hybrid_Auth::$config["debug_file"] ) && ! is_writable( Hybrid_Auth::$config["debug_file"]) ){
27
+ if ( ! touch( Hybrid_Auth::$config["debug_file"] ) ){
28
+ throw new Exception( "'debug_mode' is set to 'true', but the file " . Hybrid_Auth::$config['debug_file'] . " in 'debug_file' can not be created.", 1 );
29
+ }
30
+ }
31
+ elseif ( ! is_writable( Hybrid_Auth::$config["debug_file"] ) ){
32
throw new Exception( "'debug_mode' is set to 'true', but the given log file path 'debug_file' is not a writable file.", 1 );
33
}
34
}
35
}
36
+
37
+ /**
38
+ * Debug
39
+ * @param String $message
40
+ * @param Object $object
41
+ */
42
public static function debug( $message, $object = NULL )
43
{
44
if( Hybrid_Auth::$config["debug_mode"] ){
52
);
53
}
54
}
55
+
56
+ /**
57
+ * Info
58
+ * @param String $message
59
+ */
60
public static function info( $message )
61
{
62
+ if( in_array(Hybrid_Auth::$config["debug_mode"], array(true, 'info'), true) ){
63
$datetime = new DateTime();
64
$datetime = $datetime->format(DATE_ATOM);
65
70
);
71
}
72
}
73
+
74
+ /**
75
+ * Error
76
+ * @param String $message Error message
77
+ * @param Object $object
78
+ */
79
public static function error($message, $object = NULL)
80
{
81
+ if(isset(Hybrid_Auth::$config["debug_mode"]) && in_array(Hybrid_Auth::$config["debug_mode"], array(true, 'info', 'error'), true) ){
82
$datetime = new DateTime();
83
$datetime = $datetime->format(DATE_ATOM);
84
hybridauth/Hybrid/Provider_Adapter.php CHANGED
@@ -1,15 +1,15 @@
1
<?php
2
- /*!
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
- * (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
9
* Hybrid_Provider_Adapter is the basic class which Hybrid_Auth will use
10
* to connect users to a given provider.
11
*
12
- * Basically Hybrid_Provider_Adapterwill create a bridge from your php
13
* application to the provider api.
14
*
15
* Hybrid_Auth will automatically load Hybrid_Provider_Adapter and create
@@ -17,19 +17,34 @@
17
*/
18
class Hybrid_Provider_Adapter
19
{
20
- /* Provider ID (or unique name) */
21
public $id = NULL ;
22
23
- /* Provider adapter specific config */
24
public $config = NULL ;
25
26
- /* Provider adapter extra parameters */
27
- public $params = NULL ;
28
29
- /* Provider adapter wrapper path */
30
public $wrapper = NULL ;
31
32
- /* Provider adapter instance */
33
public $adapter = NULL ;
34
35
// --------------------------------------------------------------------
@@ -40,7 +55,7 @@ class Hybrid_Provider_Adapter
40
* @param string $id The id or name of the IDp
41
* @param array $params (optional) required parameters by the adapter
42
*/
43
- function factory( $id, $params = NULL )
44
{
45
Hybrid_Logger::info( "Enter Hybrid_Provider_Adapter::factory( $id )" );
46
@@ -67,7 +82,9 @@ class Hybrid_Provider_Adapter
67
68
# include the adapter wrapper
69
if( isset( $this->config["wrapper"] ) && is_array( $this->config["wrapper"] ) ){
70
- require_once $this->config["wrapper"]["path"];
71
72
if( ! class_exists( $this->config["wrapper"]["class"] ) ){
73
throw new Exception( "Unable to load the adapter class.", 3 );
@@ -112,7 +129,21 @@ class Hybrid_Provider_Adapter
112
$this->logout();
113
114
# get hybridauth base url
115
- $HYBRID_AUTH_URL_BASE = Hybrid_Auth::$config["base_url"];
116
117
# we make use of session_id() as storage hash to identify the current user
118
# using session_regenerate_id() will be a problem, but ..
@@ -130,9 +161,13 @@ class Hybrid_Provider_Adapter
130
# auth.done required the IDp ID
131
$this->params["login_done"] = $HYBRID_AUTH_URL_BASE . ( strpos( $HYBRID_AUTH_URL_BASE, '?' ) ? '&' : '?' ) . "hauth.done={$this->id}";
132
133
- Hybrid_Auth::storage()->set( "hauth_session.{$this->id}.hauth_return_to" , $this->params["hauth_return_to"] );
134
- Hybrid_Auth::storage()->set( "hauth_session.{$this->id}.hauth_endpoint" , $this->params["login_done"] );
135
- Hybrid_Auth::storage()->set( "hauth_session.{$this->id}.id_provider_params" , $this->params );
136
137
// store config to be used by the end point
138
Hybrid_Auth::storage()->config( "CONFIG", Hybrid_Auth::$config );
@@ -184,12 +219,16 @@ class Hybrid_Provider_Adapter
184
throw new Exception( "Call to undefined function Hybrid_Providers_{$this->id}::$name()." );
185
}
186
187
- if( count( $arguments ) ){
188
- return $this->adapter->$name( $arguments[0] );
189
- }
190
- else{
191
- return $this->adapter->$name();
192
- }
193
}
194
195
// --------------------------------------------------------------------
@@ -242,7 +281,7 @@ class Hybrid_Provider_Adapter
242
// get the stored callback url
243
$callback_url = Hybrid_Auth::storage()->get( "hauth_session.{$this->id}.hauth_return_to" );
244
245
- // remove some unneed'd stored data
246
Hybrid_Auth::storage()->delete( "hauth_session.{$this->id}.hauth_return_to" );
247
Hybrid_Auth::storage()->delete( "hauth_session.{$this->id}.hauth_endpoint" );
248
Hybrid_Auth::storage()->delete( "hauth_session.{$this->id}.id_provider_params" );
1
<?php
2
+ /**
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
+ * (c) 2009-2014, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
9
* Hybrid_Provider_Adapter is the basic class which Hybrid_Auth will use
10
* to connect users to a given provider.
11
*
12
+ * Basically Hybrid_Provider_Adapter will create a bridge from your php
13
* application to the provider api.
14
*
15
* Hybrid_Auth will automatically load Hybrid_Provider_Adapter and create
17
*/
18
class Hybrid_Provider_Adapter
19
{
20
+ /**
21
+ * Provider ID (or unique name)
22
+ * @var Numeric/String
23
+ */
24
public $id = NULL ;
25
26
+ /**
27
+ * Provider adapter specific config
28
+ * @var Array
29
+ */
30
public $config = NULL ;
31
32
+ /**
33
+ * Provider adapter extra parameters
34
+ * @var array
35
+ */
36
+ public $params = array() ;
37
38
+ /**
39
+ * Provider adapter wrapper path
40
+ * @var String
41
+ */
42
public $wrapper = NULL ;
43
44
+ /**
45
+ * Provider adapter instance
46
+ * @var object
47
+ */
48
public $adapter = NULL ;
49
50
// --------------------------------------------------------------------
55
* @param string $id The id or name of the IDp
56
* @param array $params (optional) required parameters by the adapter
57
*/
58
+ function factory( $id, $params = array() )
59
{
60
Hybrid_Logger::info( "Enter Hybrid_Provider_Adapter::factory( $id )" );
61
82
83
# include the adapter wrapper
84
if( isset( $this->config["wrapper"] ) && is_array( $this->config["wrapper"] ) ){
85
+ if (isset( $this->config["wrapper"]["path"] )) {
86
+ require_once $this->config["wrapper"]["path"];
87
+ }
88
89
if( ! class_exists( $this->config["wrapper"]["class"] ) ){
90
throw new Exception( "Unable to load the adapter class.", 3 );
129
$this->logout();
130
131
# get hybridauth base url
132
+ if (empty(Hybrid_Auth::$config["base_url"])) {
133
+ // the base url wasn't provide, so we must use the current
134
+ // url (which makes sense actually)
135
+ $url = empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off' ? 'http' : 'https';
136
+ $url .= '://' . $_SERVER['HTTP_HOST'];
137
+ $url .= $_SERVER['REQUEST_URI'];
138
+ $HYBRID_AUTH_URL_BASE = $url;
139
+ } else {
140
+ $HYBRID_AUTH_URL_BASE = Hybrid_Auth::$config["base_url"];
141
+ }
142
+
143
+ // make sure params is array
144
+ if( !is_array( $this->params ) ){
145
+ $this->params = array();
146
+ }
147
148
# we make use of session_id() as storage hash to identify the current user
149
# using session_regenerate_id() will be a problem, but ..
161
# auth.done required the IDp ID
162
$this->params["login_done"] = $HYBRID_AUTH_URL_BASE . ( strpos( $HYBRID_AUTH_URL_BASE, '?' ) ? '&' : '?' ) . "hauth.done={$this->id}";
163
164
+ if( isset( $this->params["hauth_return_to"] ) ){
165
+ Hybrid_Auth::storage()->set( "hauth_session.{$this->id}.hauth_return_to", $this->params["hauth_return_to"] );
166
+ }
167
+ if( isset( $this->params["login_done"] ) ){
168
+ Hybrid_Auth::storage()->set( "hauth_session.{$this->id}.hauth_endpoint" , $this->params["login_done"] );
169
+ }
170
+ Hybrid_Auth::storage()->set( "hauth_session.{$this->id}.id_provider_params" , $this->params );
171
172
// store config to be used by the end point
173
Hybrid_Auth::storage()->config( "CONFIG", Hybrid_Auth::$config );
219
throw new Exception( "Call to undefined function Hybrid_Providers_{$this->id}::$name()." );
220
}
221
222
+ $counter = count( $arguments );
223
+ if( $counter == 1 ){
224
+ return $this->adapter->$name( $arguments[0] );
225
+ }
226
+ elseif( $counter == 2 ){
227
+ return $this->adapter->$name( $arguments[0], $arguments[1] );
228
+ }
229
+ else{
230
+ return $this->adapter->$name();
231
+ }
232
}
233
234
// --------------------------------------------------------------------
281
// get the stored callback url
282
$callback_url = Hybrid_Auth::storage()->get( "hauth_session.{$this->id}.hauth_return_to" );
283
284
+ // remove some unneeded stored data
285
Hybrid_Auth::storage()->delete( "hauth_session.{$this->id}.hauth_return_to" );
286
Hybrid_Auth::storage()->delete( "hauth_session.{$this->id}.hauth_endpoint" );
287
Hybrid_Auth::storage()->delete( "hauth_session.{$this->id}.id_provider_params" );
hybridauth/Hybrid/Provider_Model.php CHANGED
@@ -1,8 +1,8 @@
1
<?php
2
- /*!
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
- * (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
@@ -21,27 +21,48 @@
21
*/
22
abstract class Hybrid_Provider_Model
23
{
24
- /* IDp ID (or unique name) */
25
public $providerId = NULL;
26
27
- /* specific provider adapter config */
28
public $config = NULL;
29
30
- /* provider extra parameters */
31
public $params = NULL;
32
33
- /* Endpoint URL for that provider */
34
public $endpoint = NULL;
35
36
- /* Hybrid_User obj, represents the current loggedin user */
37
public $user = NULL;
38
39
- /* the provider api client (optional) */
40
public $api = NULL;
41
42
/**
43
- * common providers adapter constructor
44
- */
45
function __construct( $providerId, $config, $params = NULL )
46
{
47
# init the IDp adapter parameters, get them from the cache if possible
@@ -77,7 +98,7 @@ abstract class Hybrid_Provider_Model
77
* IDp wrappers initializer
78
*
79
* The main job of wrappers initializer is to performs (depend on the IDp api client it self):
80
- * - include some libs nedded by this provider,
81
* - check IDp key and secret,
82
* - set some needed parameters (stored in $this->params) by this IDp api client
83
* - create and setup an instance of the IDp api client on $this->api
@@ -119,7 +140,7 @@ abstract class Hybrid_Provider_Model
119
*/
120
function getUserProfile()
121
{
122
- Hybrid_Logger::error( "HybridAuth do not provide users contats list for {$this->providerId} yet." );
123
124
throw new Exception( "Provider does not support this feature.", 8 );
125
}
@@ -131,7 +152,7 @@ abstract class Hybrid_Provider_Model
131
*/
132
function getUserContacts()
133
{
134
- Hybrid_Logger::error( "HybridAuth do not provide users contats list for {$this->providerId} yet." );
135
136
throw new Exception( "Provider does not support this feature.", 8 );
137
}
@@ -151,7 +172,7 @@ abstract class Hybrid_Provider_Model
151
// --------------------------------------------------------------------
152
153
/**
154
- * return the user activity stream
155
*/
156
function setUserStatus( $status )
157
{
@@ -160,6 +181,17 @@ abstract class Hybrid_Provider_Model
160
throw new Exception( "Provider does not support this feature.", 8 );
161
}
162
163
// --------------------------------------------------------------------
164
165
/**
@@ -222,7 +254,7 @@ abstract class Hybrid_Provider_Model
222
// --------------------------------------------------------------------
223
224
/**
225
- * clear all existen tokens for this provider
226
*/
227
public function clearTokens()
228
{
1
<?php
2
+ /**
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
+ * (c) 2009-2014, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
21
*/
22
abstract class Hybrid_Provider_Model
23
{
24
+ /**
25
+ * IDp ID (or unique name)
26
+ * @var Numeric/String
27
+ */
28
public $providerId = NULL;
29
30
+ /**
31
+ * specific provider adapter config
32
+ * @var array
33
+ */
34
public $config = NULL;
35
36
+ /**
37
+ * provider extra parameters
38
+ * @var array
39
+ */
40
public $params = NULL;
41
42
+ /**
43
+ * Endpoint URL for that provider
44
+ * @var String
45
+ */
46
public $endpoint = NULL;
47
48
+ /**
49
+ * Hybrid_User obj, represents the current loggedin user
50
+ * @var object
51
+ */
52
public $user = NULL;
53
54
+ /**
55
+ * the provider api client (optional)
56
+ * @var String
57
+ */
58
public $api = NULL;
59
60
/**
61
+ * Common providers adapter constructor
62
+ * @param Numeric/String $providerId
63
+ * @param Array $config
64
+ * @param Array $params
65
+ */
66
function __construct( $providerId, $config, $params = NULL )
67
{
68
# init the IDp adapter parameters, get them from the cache if possible
98
* IDp wrappers initializer
99
*
100
* The main job of wrappers initializer is to performs (depend on the IDp api client it self):
101
+ * - include some libs needed by this provider,
102
* - check IDp key and secret,
103
* - set some needed parameters (stored in $this->params) by this IDp api client
104
* - create and setup an instance of the IDp api client on $this->api
140
*/
141
function getUserProfile()
142
{
143
+ Hybrid_Logger::error( "HybridAuth do not provide users contacts list for {$this->providerId} yet." );
144
145
throw new Exception( "Provider does not support this feature.", 8 );
146
}
152
*/
153
function getUserContacts()
154
{
155
+ Hybrid_Logger::error( "HybridAuth do not provide users contacts list for {$this->providerId} yet." );
156
157
throw new Exception( "Provider does not support this feature.", 8 );
158
}
172
// --------------------------------------------------------------------
173
174
/**
175
+ * set user status
176
*/
177
function setUserStatus( $status )
178
{
181
throw new Exception( "Provider does not support this feature.", 8 );
182
}
183
184
+
185
+ /**
186
+ * return the user status
187
+ */
188
+ function getUserStatus( $statusid )
189
+ {
190
+ Hybrid_Logger::error( "HybridAuth do not provide user's status for {$this->providerId} yet." );
191
+
192
+ throw new Exception( "Provider does not support this feature.", 8 );
193
+ }
194
+
195
// --------------------------------------------------------------------
196
197
/**
254
// --------------------------------------------------------------------
255
256
/**
257
+ * clear all existent tokens for this provider
258
*/
259
public function clearTokens()
260
{
hybridauth/Hybrid/Provider_Model_OAuth1.php CHANGED
@@ -1,15 +1,15 @@
1
<?php
2
- /*!
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
- * (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
9
* To implement an OAuth 1 based service provider, Hybrid_Provider_Model_OAuth1
10
* can be used to save the hassle of the authentication flow.
11
*
12
- * Each class that inherit from Hybrid_Provider_Model_OAuth1 have to implemenent
13
* at least 2 methods:
14
* Hybrid_Providers_{provider_name}::initialize() to setup the provider api end-points urls
15
* Hybrid_Providers_{provider_name}::getUserProfile() to grab the user profile
@@ -19,11 +19,21 @@
19
*/
20
class Hybrid_Provider_Model_OAuth1 extends Hybrid_Provider_Model
21
{
22
- public $request_tokens_raw = null; // request_tokens as recived from provider
23
- public $access_tokens_raw = null; // access_tokens as recived from provider
24
25
/**
26
- * try to get the error message from provider api
27
*/
28
function errorMessageByStatus( $code = null ) {
29
$http_status_codes = ARRAY(
@@ -98,7 +108,7 @@ class Hybrid_Provider_Model_OAuth1 extends Hybrid_Provider_Model
98
{
99
$tokens = $this->api->requestToken( $this->endpoint );
100
101
- // request tokens as recived from provider
102
$this->request_tokens_raw = $tokens;
103
104
// check the last HTTP status code returned
@@ -134,7 +144,7 @@ class Hybrid_Provider_Model_OAuth1 extends Hybrid_Provider_Model
134
// request an access token
135
$tokens = $this->api->accessToken( $oauth_verifier );
136
137
- // access tokens as recived from provider
138
$this->access_tokens_raw = $tokens;
139
140
// check the last HTTP status code returned
@@ -147,11 +157,11 @@ class Hybrid_Provider_Model_OAuth1 extends Hybrid_Provider_Model
147
throw new Exception( "Authentication failed! {$this->providerId} returned an invalid access token.", 5 );
148
}
149
150
- // we no more need to store requet tokens
151
$this->deleteToken( "request_token" );
152
$this->deleteToken( "request_token_secret" );
153
154
- // sotre access_token for later user
155
$this->token( "access_token" , $tokens['oauth_token'] );
156
$this->token( "access_token_secret" , $tokens['oauth_token_secret'] );
157
1
<?php
2
+ /**
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
+ * (c) 2009-2014, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
9
* To implement an OAuth 1 based service provider, Hybrid_Provider_Model_OAuth1
10
* can be used to save the hassle of the authentication flow.
11
*
12
+ * Each class that inherit from Hybrid_Provider_Model_OAuth1 have to implement
13
* at least 2 methods:
14
* Hybrid_Providers_{provider_name}::initialize() to setup the provider api end-points urls
15
* Hybrid_Providers_{provider_name}::getUserProfile() to grab the user profile
19
*/
20
class Hybrid_Provider_Model_OAuth1 extends Hybrid_Provider_Model
21
{
22
+ /**
23
+ * request_tokens as received from provider
24
+ * @var object
25
+ */
26
+ public $request_tokens_raw = null;
27
+
28
+ /**
29
+ * access_tokens as received from provider
30
+ * @var object
31
+ */
32
+ public $access_tokens_raw = null;
33
34
/**
35
+ * Try to get the error message from provider api
36
+ * @param Numeric $code
37
*/
38
function errorMessageByStatus( $code = null ) {
39
$http_status_codes = ARRAY(
108
{
109
$tokens = $this->api->requestToken( $this->endpoint );
110
111
+ // request tokens as received from provider
112
$this->request_tokens_raw = $tokens;
113
114
// check the last HTTP status code returned
144
// request an access token
145
$tokens = $this->api->accessToken( $oauth_verifier );
146
147
+ // access tokens as received from provider
148
$this->access_tokens_raw = $tokens;
149
150
// check the last HTTP status code returned
157
throw new Exception( "Authentication failed! {$this->providerId} returned an invalid access token.", 5 );
158
}
159
160
+ // we no more need to store request tokens
161
$this->deleteToken( "request_token" );
162
$this->deleteToken( "request_token_secret" );
163
164
+ // store access_token for later user
165
$this->token( "access_token" , $tokens['oauth_token'] );
166
$this->token( "access_token_secret" , $tokens['oauth_token_secret'] );
167
hybridauth/Hybrid/Provider_Model_OAuth2.php CHANGED
@@ -1,15 +1,15 @@
1
<?php
2
- /*!
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
- * (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
9
* To implement an OAuth 2 based service provider, Hybrid_Provider_Model_OAuth2
10
* can be used to save the hassle of the authentication flow.
11
*
12
- * Each class that inherit from Hybrid_Provider_Model_OAuth2 have to implemenent
13
* at least 2 methods:
14
* Hybrid_Providers_{provider_name}::initialize() to setup the provider api end-points urls
15
* Hybrid_Providers_{provider_name}::getUserProfile() to grab the user profile
@@ -18,12 +18,16 @@
18
* Hybrid/thirdparty/OAuth/OAuth2Client.php
19
*/
20
class Hybrid_Provider_Model_OAuth2 extends Hybrid_Provider_Model
21
- {
22
- // default permissions
23
public $scope = "";
24
25
/**
26
- * try to get the error message from provider api
27
*/
28
function errorMessageByStatus( $code = null ) {
29
$http_status_codes = ARRAY(
@@ -53,6 +57,10 @@ class Hybrid_Provider_Model_OAuth2 extends Hybrid_Provider_Model
53
*/
54
function initialize()
55
{
56
if ( ! $this->config["keys"]["id"] || ! $this->config["keys"]["secret"] ){
57
throw new Exception( "Your application id and secret are required in order to connect to {$this->providerId}.", 4 );
58
}
@@ -107,7 +115,7 @@ class Hybrid_Provider_Model_OAuth2 extends Hybrid_Provider_Model
107
throw new Exception( "Authentication failed! {$this->providerId} returned an error: $error", 5 );
108
}
109
110
- // try to authenicate user
111
$code = (array_key_exists('code',$_REQUEST))?$_REQUEST['code']:"";
112
113
try{
1
<?php
2
+ /**
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
+ * (c) 2009-2014, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
9
* To implement an OAuth 2 based service provider, Hybrid_Provider_Model_OAuth2
10
* can be used to save the hassle of the authentication flow.
11
*
12
+ * Each class that inherit from Hybrid_Provider_Model_OAuth2 have to implement
13
* at least 2 methods:
14
* Hybrid_Providers_{provider_name}::initialize() to setup the provider api end-points urls
15
* Hybrid_Providers_{provider_name}::getUserProfile() to grab the user profile
18
* Hybrid/thirdparty/OAuth/OAuth2Client.php
19
*/
20
class Hybrid_Provider_Model_OAuth2 extends Hybrid_Provider_Model
21
+ {
22
+ /**
23
+ * default permissions
24
+ * @var string
25
+ */
26
public $scope = "";
27
28
/**
29
+ * Try to get the error message from provider api
30
+ * @param Numeric $code
31
*/
32
function errorMessageByStatus( $code = null ) {
33
$http_status_codes = ARRAY(
57
*/
58
function initialize()
59
{
60
+ if ( ! isset( $this->config["keys"]["id"] ) || ! isset( $this->config["keys"]["secret"] ) ){
61
+ throw new Exception( "Your application id and secret are required in order to connect to {$this->providerId}.", 4 );
62
+ }
63
+
64
if ( ! $this->config["keys"]["id"] || ! $this->config["keys"]["secret"] ){
65
throw new Exception( "Your application id and secret are required in order to connect to {$this->providerId}.", 4 );
66
}
115
throw new Exception( "Authentication failed! {$this->providerId} returned an error: $error", 5 );
116
}
117
118
+ // try to authenticate user
119
$code = (array_key_exists('code',$_REQUEST))?$_REQUEST['code']:"";
120
121
try{
hybridauth/Hybrid/Provider_Model_OpenID.php CHANGED
@@ -1,14 +1,14 @@
1
<?php
2
- /*!
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
- * (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
9
* To implement an OpenID based service provider, Hybrid_Provider_Model_OpenID
10
- * can be used to save the hassle of the authentication flow.
11
- *
12
* Each class that inherit from Hybrid_Provider_Model_OAuth2 have only to define
13
* the provider identifier : <code>public $openidIdentifier = ""; </code>
14
*
@@ -17,13 +17,16 @@
17
*/
18
class Hybrid_Provider_Model_OpenID extends Hybrid_Provider_Model
19
{
20
- /* Openid provider identifier */
21
- public $openidIdentifier = "";
22
23
// --------------------------------------------------------------------
24
25
/**
26
- * adapter initializer
27
*/
28
function initialize()
29
{
@@ -32,18 +35,26 @@ class Hybrid_Provider_Model_OpenID extends Hybrid_Provider_Model
32
}
33
34
// include LightOpenID lib
35
- require_once Hybrid_Auth::$config["path_libraries"] . "OpenID/LightOpenID.php";
36
-
37
// An error was occurring when proxy wasn't set. Not sure where proxy was meant to be set/initialized.
38
Hybrid_Auth::$config['proxy'] = isset(Hybrid_Auth::$config['proxy'])?Hybrid_Auth::$config['proxy']:'';
39
-
40
- $this->api = new LightOpenID( parse_url( Hybrid_Auth::$config["base_url"], PHP_URL_HOST), Hybrid_Auth::$config["proxy"] );
41
}
42
43
// --------------------------------------------------------------------
44
45
/**
46
- * begin login step
47
*/
48
function loginBegin()
49
{
@@ -53,7 +64,7 @@ class Hybrid_Provider_Model_OpenID extends Hybrid_Provider_Model
53
54
$this->api->identity = $this->openidIdentifier;
55
$this->api->returnUrl = $this->endpoint;
56
- $this->api->required = ARRAY(
57
'namePerson/first' ,
58
'namePerson/last' ,
59
'namePerson/friendly' ,
@@ -67,11 +78,11 @@ class Hybrid_Provider_Model_OpenID extends Hybrid_Provider_Model
67
'birthDate/birthYear' ,
68
69
'person/gender' ,
70
- 'pref/language' ,
71
72
'contact/postalCode/home',
73
'contact/city/home' ,
74
- 'contact/country/home' ,
75
76
'media/image/default' ,
77
);
@@ -83,24 +94,24 @@ class Hybrid_Provider_Model_OpenID extends Hybrid_Provider_Model
83
// --------------------------------------------------------------------
84
85
/**
86
- * finish login step
87
*/
88
function loginFinish()
89
{
90
- # if user don't garant acess of their data to your site, halt with an Exception
91
if( $this->api->mode == 'cancel'){
92
throw new Exception( "Authentication failed! User has canceled authentication!", 5 );
93
}
94
95
# if something goes wrong
96
if( ! $this->api->validate() ){
97
- throw new Exception( "Authentication failed. Invalid request recived!", 5 );
98
}
99
100
- # fetch recived user data
101
$response = $this->api->getAttributes();
102
103
- # sotre the user profile
104
$this->user->profile->identifier = $this->api->identity;
105
106
$this->user->profile->firstName = (array_key_exists("namePerson/first",$response))?$response["namePerson/first"]:"";
@@ -108,25 +119,21 @@ class Hybrid_Provider_Model_OpenID extends Hybrid_Provider_Model
108
$this->user->profile->displayName = (array_key_exists("namePerson",$response))?$response["namePerson"]:"";
109
$this->user->profile->email = (array_key_exists("contact/email",$response))?$response["contact/email"]:"";
110
$this->user->profile->language = (array_key_exists("pref/language",$response))?$response["pref/language"]:"";
111
- $this->user->profile->country = (array_key_exists("contact/country/home",$response))?$response["contact/country/home"]:"";
112
- $this->user->profile->zip = (array_key_exists("contact/postalCode/home",$response))?$response["contact/postalCode/home"]:"";
113
- $this->user->profile->gender = (array_key_exists("person/gender",$response))?$response["person/gender"]:"";
114
- $this->user->profile->photoURL = (array_key_exists("media/image/default",$response))?$response["media/image/default"]:"";
115
-
116
- $this->user->profile->birthDay = (array_key_exists("birthDate/birthDay",$response))?$response["birthDate/birthDay"]:"";
117
- $this->user->profile->birthMonth = (array_key_exists("birthDate/birthMonth",$response))?$response["birthDate/birthMonth"]:"";
118
- $this->user->profile->birthYear = (array_key_exists("birthDate/birthDate",$response))?$response["birthDate/birthDate"]:"";
119
120
- if( ! $this->user->profile->displayName ) {
121
- $this->user->profile->displayName = trim( $this->user->profile->lastName . " " . $this->user->profile->firstName );
122
- }
123
124
- if( isset( $response['namePerson/friendly'] ) && ! empty( $response['namePerson/friendly'] ) && ! $this->user->profile->displayName ) {
125
- $this->user->profile->displayName = (array_key_exists("namePerson/friendly",$response))?$response["namePerson/friendly"]:"" ;
126
}
127
128
if( isset( $response['birthDate'] ) && ! empty( $response['birthDate'] ) && ! $this->user->profile->birthDay ) {
129
- list( $birthday_year, $birthday_month, $birthday_day ) = (array_key_exists('birthDate',$response))?$response['birthDate']:"";
130
131
$this->user->profile->birthDay = (int) $birthday_day;
132
$this->user->profile->birthMonth = (int) $birthday_month;
@@ -143,12 +150,12 @@ class Hybrid_Provider_Model_OpenID extends Hybrid_Provider_Model
143
144
if( $this->user->profile->gender == "m" ){
145
$this->user->profile->gender = "male";
146
- }
147
148
// set user as logged in
149
$this->setUserConnected();
150
151
- // with openid providers we get the user profile only once, so store it
152
Hybrid_Auth::storage()->set( "hauth_session.{$this->providerId}.user", $this->user );
153
}
154
@@ -165,7 +172,7 @@ class Hybrid_Provider_Model_OpenID extends Hybrid_Provider_Model
165
// if not found
166
if ( ! is_object( $this->user ) ){
167
throw new Exception( "User profile request failed! User is not connected to {$this->providerId} or his session has expired.", 6 );
168
- }
169
170
return $this->user->profile;
171
}
1
<?php
2
+ /**
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
+ * (c) 2009-2014, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
9
* To implement an OpenID based service provider, Hybrid_Provider_Model_OpenID
10
+ * can be used to save the hassle of the authentication flow.
11
+ *
12
* Each class that inherit from Hybrid_Provider_Model_OAuth2 have only to define
13
* the provider identifier : <code>public $openidIdentifier = ""; </code>
14
*
17
*/
18
class Hybrid_Provider_Model_OpenID extends Hybrid_Provider_Model
19
{
20
+ /**
21
+ * Openid provider identifier
22
+ * @var string
23
+ */
24
+ public $openidIdentifier = "";
25
26
// --------------------------------------------------------------------
27
28
/**
29
+ * adapter initializer
30
*/
31
function initialize()
32
{
35
}
36
37
// include LightOpenID lib
38
+ require_once Hybrid_Auth::$config["path_libraries"] . "OpenID/LightOpenID.php";
39
+
40
// An error was occurring when proxy wasn't set. Not sure where proxy was meant to be set/initialized.
41
Hybrid_Auth::$config['proxy'] = isset(Hybrid_Auth::$config['proxy'])?Hybrid_Auth::$config['proxy']:'';
42
+
43
+ $hostPort = parse_url( Hybrid_Auth::$config["base_url"], PHP_URL_PORT);
44
+ $hostUrl = parse_url( Hybrid_Auth::$config["base_url"], PHP_URL_HOST);
45
+
46
+ // Check for port on url
47
+ if($hostPort) {
48
+ $hostUrl .= ':'.$hostPort;
49
+ }
50
+
51
+ $this->api = new LightOpenID( $hostUrl, Hybrid_Auth::$config["proxy"] );
52
}
53
54
// --------------------------------------------------------------------
55
56
/**
57
+ * begin login step
58
*/
59
function loginBegin()
60
{
64
65
$this->api->identity = $this->openidIdentifier;
66
$this->api->returnUrl = $this->endpoint;
67
+ $this->api->required = ARRAY(
68
'namePerson/first' ,
69
'namePerson/last' ,
70
'namePerson/friendly' ,
78
'birthDate/birthYear' ,
79
80
'person/gender' ,
81
+ 'pref/language' ,
82
83
'contact/postalCode/home',
84
'contact/city/home' ,
85
+ 'contact/country/home' ,
86
87
'media/image/default' ,
88
);
94
// --------------------------------------------------------------------
95
96
/**
97
+ * finish login step
98
*/
99
function loginFinish()
100
{
101
+ # if user don't grant access of their data to your site, halt with an Exception
102
if( $this->api->mode == 'cancel'){
103
throw new Exception( "Authentication failed! User has canceled authentication!", 5 );
104
}
105
106
# if something goes wrong
107
if( ! $this->api->validate() ){
108
+ throw new Exception( "Authentication failed. Invalid request received!", 5 );
109
}
110
111
+ # fetch received user data
112
$response = $this->api->getAttributes();
113
114
+ # store the user profile
115
$this->user->profile->identifier = $this->api->identity;
116
117
$this->user->profile->firstName = (array_key_exists("namePerson/first",$response))?$response["namePerson/first"]:"";
119
$this->user->profile->displayName = (array_key_exists("namePerson",$response))?$response["namePerson"]:"";
120
$this->user->profile->email = (array_key_exists("contact/email",$response))?$response["contact/email"]:"";
121
$this->user->profile->language = (array_key_exists("pref/language",$response))?$response["pref/language"]:"";
122
+ $this->user->profile->country = (array_key_exists("contact/country/home",$response))?$response["contact/country/home"]:"";
123
+ $this->user->profile->zip = (array_key_exists("contact/postalCode/home",$response))?$response["contact/postalCode/home"]:"";
124
+ $this->user->profile->gender = (array_key_exists("person/gender",$response))?$response["person/gender"]:"";
125
+ $this->user->profile->photoURL = (array_key_exists("media/image/default",$response))?$response["media/image/default"]:"";
126
127
+ $this->user->profile->birthDay = (array_key_exists("birthDate/birthDay",$response))?$response["birthDate/birthDay"]:"";
128
+ $this->user->profile->birthMonth = (array_key_exists("birthDate/birthMonth",$response))?$response["birthDate/birthMonth"]:"";
129
+ $this->user->profile->birthYear = (array_key_exists("birthDate/birthDate",$response))?$response["birthDate/birthDate"]:"";
130
131
+ if( isset( $response['namePerson/friendly'] ) && ! empty( $response['namePerson/friendly'] ) && ! $this->user->profile->displayName ) {
132
+ $this->user->profile->displayName = $response["namePerson/friendly"];
133
}
134
135
if( isset( $response['birthDate'] ) && ! empty( $response['birthDate'] ) && ! $this->user->profile->birthDay ) {
136
+ list( $birthday_year, $birthday_month, $birthday_day ) = $response['birthDate'];
137
138
$this->user->profile->birthDay = (int) $birthday_day;
139
$this->user->profile->birthMonth = (int) $birthday_month;
150
151
if( $this->user->profile->gender == "m" ){
152
$this->user->profile->gender = "male";
153
+ }
154
155
// set user as logged in
156
$this->setUserConnected();
157
158
+ // with openid providers we get the user profile only once, so store it
159
Hybrid_Auth::storage()->set( "hauth_session.{$this->providerId}.user", $this->user );
160
}
161
172
// if not found
173
if ( ! is_object( $this->user ) ){
174
throw new Exception( "User profile request failed! User is not connected to {$this->providerId} or his session has expired.", 6 );
175
+ }
176
177
return $this->user->profile;
178
}
hybridauth/Hybrid/Providers/Disqus.php ADDED
@@ -0,0 +1,59 @@
1
+ <?php
2
+ /*!
3
+ * HybridAuth
4
+ * http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
5
+ * (c) 2009-2014 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
6
+ */
7
+
8
+ /**
9
+ * Hybrid_Providers_Disqus
10
+ */
11
+ class Hybrid_Providers_Disqus extends Hybrid_Provider_Model_OAuth2
12
+ {
13
+ // default permissions
14
+ // (read,email) => public info and email
15
+ public $scope = "read,email";
16
+
17
+ /**
18
+ * IDp wrappers initializer
19
+ */
20
+ function initialize()
21
+ {
22
+ parent::initialize();
23
+
24
+ // Provider api end-points
25
+ $this->api->api_base_url = "https://disqus.com/api/3.0/";
26
+ $this->api->authorize_url = "https://disqus.com/api/oauth/2.0/authorize";
27
+ $this->api->token_url = "https://disqus.com/api/oauth/2.0/access_token/";
28
+
29
+ }
30
+
31
+ /**
32
+ * load the user profile from the IDp api client
33
+ */
34
+ function getUserProfile()
35
+ {
36
+ $data = $this->api->get( "users/details" , array('api_key' => $this->api->client_id, 'api_secret' => $this->api->client_secret));
37
+
38
+ if ( ! isset( $data->code ) ){
39
+ throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
40
+ } else if ( $data->code != 0 ){
41
+ throw new Exception( "User profile request failed! {$this->providerId} returned error code".$data->code.".", 6 );
42
+ }
43
+
44
+ $this->user->profile->identifier = @ $data->response->id;
45
+ $this->user->profile->displayName = @ $data->response->name;
46
+ $this->user->profile->description = @ $data->response->bio;
47
+ $this->user->profile->photoURL = @ $data->response->avatar->permalink;
48
+ $this->user->profile->profileURL = @ $data->response->profileUrl;
49
+ $this->user->profile->email = @ $data->response->email;
50
+ $this->user->profile->region = @ $data->response->location;
51
+ $this->user->profile->description = @ $data->response->about;
52
+
53
+ if( ! $this->user->profile->displayName ){
54
+ $this->user->profile->displayName = @ $data->response->username;
55
+ }
56
+
57
+ return $this->user->profile;
58
+ }
59
+ }
hybridauth/Hybrid/Providers/Facebook.php CHANGED
@@ -14,8 +14,8 @@
14
*/
15
class Hybrid_Providers_Facebook extends Hybrid_Provider_Model
16
{
17
- // default permissions, and alot of them. You can change them from the configuration by setting the scope to what you want/need
18
- public $scope = "email, user_about_me, user_birthday, user_hometown, user_website, read_stream, offline_access, publish_stream, read_friendlists";
19
20
/**
21
* IDp wrappers initializer
@@ -30,10 +30,13 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model
30
require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/base_facebook.php";
31
require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/facebook.php";
32
}
33
34
- BaseFacebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;
35
-
36
- $this->api = new Facebook( ARRAY( 'appId' => $this->config["keys"]["id"], 'secret' => $this->config["keys"]["secret"] ) );
37
38
if ( $this->token("access_token") ) {
39
$this->api->setAccessToken( $this->token("access_token") );
@@ -59,14 +62,29 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model
59
function loginBegin()
60
{
61
$parameters = array("scope" => $this->scope, "redirect_uri" => $this->endpoint, "display" => "page");
62
- $optionals = array("scope", "redirect_uri", "display");
63
64
foreach ($optionals as $parameter){
65
if( isset( $this->config[$parameter] ) && ! empty( $this->config[$parameter] ) ){
66
$parameters[$parameter] = $this->config[$parameter];
67
}
68
}
69
70
// get the login url
71
$url = $this->api->getLoginUrl( $parameters );
72
@@ -84,6 +102,35 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model
84
throw new Exception( "Authentication failed! The user denied your request.", 5 );
85
}
86
87
// try to get the UID of the connected user from fb, should be > 0
88
if ( ! $this->api->getUser() ){
89
throw new Exception( "Authentication failed! {$this->providerId} returned an invalid user id.", 5 );
@@ -119,25 +166,36 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model
119
throw new Exception( "User profile request failed! {$this->providerId} returned an error: $e", 6 );
120
}
121
122
- // if the provider identifier is not recived, we assume the auth has failed
123
if ( ! isset( $data["id"] ) ){
124
throw new Exception( "User profile request failed! {$this->providerId} api returned an invalid response.", 6 );
125
}
126
127
# store the user profile.
128
$this->user->profile->identifier = (array_key_exists('id',$data))?$data['id']:"";
129
$this->user->profile->displayName = (array_key_exists('name',$data))?$data['name']:"";
130
$this->user->profile->firstName = (array_key_exists('first_name',$data))?$data['first_name']:"";
131
$this->user->profile->lastName = (array_key_exists('last_name',$data))?$data['last_name']:"";
132
$this->user->profile->photoURL = "https://graph.facebook.com/" . $this->user->profile->identifier . "/picture?width=150&height=150";
133
$this->user->profile->profileURL = (array_key_exists('link',$data))?$data['link']:"";
134
$this->user->profile->webSiteURL = (array_key_exists('website',$data))?$data['website']:"";
135
$this->user->profile->gender = (array_key_exists('gender',$data))?$data['gender']:"";
136
- $this->user->profile->description = (array_key_exists('bio',$data))?$data['bio']:"";
137
$this->user->profile->email = (array_key_exists('email',$data))?$data['email']:"";
138
$this->user->profile->emailVerified = (array_key_exists('email',$data))?$data['email']:"";
139
$this->user->profile->region = (array_key_exists("hometown",$data)&&array_key_exists("name",$data['hometown']))?$data['hometown']["name"]:"";
140
-
141
if( array_key_exists('birthday',$data) ) {
142
list($birthday_month, $birthday_day, $birthday_year) = explode( "/", $data['birthday'] );
143
@@ -149,30 +207,67 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model
149
return $this->user->profile;
150
}
151
152
/**
153
* load the user contacts
154
*/
155
function getUserContacts()
156
{
157
- try{
158
- $response = $this->api->api('/me/friends');
159
- }
160
- catch( FacebookApiException $e ){
161
- throw new Exception( "User contacts request failed! {$this->providerId} returned an error: $e" );
162
- }
163
-
164
- if( ! $response || ! count( $response["data"] ) ){
165
- return ARRAY();
166
}
167
168
$contacts = ARRAY();
169
170
- foreach( $response["data"] as $item ){
171
$uc = new Hybrid_User_Contact();
172
173
$uc->identifier = (array_key_exists("id",$item))?$item["id"]:"";
174
$uc->displayName = (array_key_exists("name",$item))?$item["name"]:"";
175
- $uc->profileURL = "https://www.facebook.com/profile.php?id=" . $uc->identifier;
176
$uc->photoURL = "https://graph.facebook.com/" . $uc->identifier . "/picture?width=150&height=150";
177
178
$contacts[] = $uc;
@@ -181,27 +276,96 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model
181
return $contacts;
182
}
183
184
- /**
185
- * update user status
186
- */
187
- function setUserStatus( $status )
188
- {
189
- $parameters = array();
190
191
- if( is_array( $status ) ){
192
- $parameters = $status;
193
- }
194
- else{
195
- $parameters["message"] = $status;
196
- }
197
198
- try{
199
- $response = $this->api->api( "/me/feed", "post", $parameters );
200
- }
201
catch( FacebookApiException $e ){
202
- throw new Exception( "Update user status failed! {$this->providerId} returned an error: $e" );
203
}
204
- }
205
206
/**
207
* load the user latest activity
14
*/
15
class Hybrid_Providers_Facebook extends Hybrid_Provider_Model
16
{
17
+ // default permissions, and a lot of them. You can change them from the configuration by setting the scope to what you want/need
18
+ public $scope = "email, user_about_me, user_birthday, user_hometown, user_website, read_stream, publish_actions, read_friendlists";
19
20
/**
21
* IDp wrappers initializer
30
require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/base_facebook.php";
31
require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/facebook.php";
32
}
33
+
34
+ if ( isset ( Hybrid_Auth::$config["proxy"] ) ) {
35
+ BaseFacebook::$CURL_OPTS[CURLOPT_PROXY] = Hybrid_Auth::$config["proxy"];
36
+ }
37
38
+ $trustForwarded = isset( $this->config['trustForwarded'] ) ? (bool) $this->config['trustForwarded'] : false;
39
+ $this->api = new Facebook( ARRAY( 'appId' => $this->config["keys"]["id"], 'secret' => $this->config["keys"]["secret"], 'trustForwarded' => $trustForwarded ) );
40
41
if ( $this->token("access_token") ) {
42
$this->api->setAccessToken( $this->token("access_token") );
62
function loginBegin()
63
{
64
$parameters = array("scope" => $this->scope, "redirect_uri" => $this->endpoint, "display" => "page");
65
+ $optionals = array("scope", "redirect_uri", "display", "auth_type");
66
67
foreach ($optionals as $parameter){
68
if( isset( $this->config[$parameter] ) && ! empty( $this->config[$parameter] ) ){
69
$parameters[$parameter] = $this->config[$parameter];
70
+
71
+ //If the auth_type parameter is used, we need to generate a nonce and include it as a parameter
72
+ if($parameter == "auth_type"){
73
+ $nonce = md5(uniqid(mt_rand(), true));
74
+ $parameters['auth_nonce'] = $nonce;
75
+
76
+ Hybrid_Auth::storage()->set('fb_auth_nonce', $nonce);
77
+ }
78
}
79
}
80
81
+ if( isset( $this->config[ 'force' ] ) && $this->config[ 'force' ] === true ){
82
+ $parameters[ 'auth_type' ] = 'reauthenticate';
83
+ $parameters[ 'auth_nonce' ] = md5( uniqid( mt_rand(), true ) );
84
+
85
+ Hybrid_Auth::storage()->set( 'fb_auth_nonce', $parameters[ 'auth_nonce' ] );
86
+ }
87
+
88
// get the login url
89
$url = $this->api->getLoginUrl( $parameters );
90
102
throw new Exception( "Authentication failed! The user denied your request.", 5 );
103
}
104
105
+ // in case we are using iOS/Facebook reverse authentication
106
+ if(isset($_REQUEST['access_token'])){
107
+ $this->token("access_token", $_REQUEST['access_token'] );
108
+ $this->api->setAccessToken( $this->token("access_token") );
109
+ $this->api->setExtendedAccessToken();
110
+ $access_token = $this->api->getAccessToken();
111
+
112
+ if( $access_token ){
113
+ $this->token("access_token", $access_token );
114
+ $this->api->setAccessToken( $access_token );
115
+ }
116
+
117
+ $this->api->setAccessToken( $this->token("access_token") );
118
+ }
119
+
120
+
121
+ // if auth_type is used, then an auth_nonce is passed back, and we need to check it.
122
+ if(isset($_REQUEST['auth_nonce'])){
123
+
124
+ $nonce = Hybrid_Auth::storage()->get('fb_auth_nonce');
125
+
126
+ //Delete the nonce
127
+ Hybrid_Auth::storage()->delete('fb_auth_nonce');
128
+
129
+ if($_REQUEST['auth_nonce'] != $nonce){
130
+ throw new Exception( "Authentication failed! Invalid nonce used for reauthentication.", 5 );
131
+ }
132
+ }
133
+
134
// try to get the UID of the connected user from fb, should be > 0
135
if ( ! $this->api->getUser() ){
136
throw new Exception( "Authentication failed! {$this->providerId} returned an invalid user id.", 5 );
166
throw new Exception( "User profile request failed! {$this->providerId} returned an error: $e", 6 );
167
}
168
169
+ // if the provider identifier is not received, we assume the auth has failed
170
if ( ! isset( $data["id"] ) ){
171
throw new Exception( "User profile request failed! {$this->providerId} api returned an invalid response.", 6 );
172
}
173
174
# store the user profile.
175
$this->user->profile->identifier = (array_key_exists('id',$data))?$data['id']:"";
176
+ $this->user->profile->username = (array_key_exists('username',$data))?$data['username']:"";
177
$this->user->profile->displayName = (array_key_exists('name',$data))?$data['name']:"";
178
$this->user->profile->firstName = (array_key_exists('first_name',$data))?$data['first_name']:"";
179
$this->user->profile->lastName = (array_key_exists('last_name',$data))?$data['last_name']:"";
180
$this->user->profile->photoURL = "https://graph.facebook.com/" . $this->user->profile->identifier . "/picture?width=150&height=150";
181
+ $this->user->profile->coverInfoURL = "https://graph.facebook.com/" . $this->user->profile->identifier . "?fields=cover";
182
$this->user->profile->profileURL = (array_key_exists('link',$data))?$data['link']:"";
183
$this->user->profile->webSiteURL = (array_key_exists('website',$data))?$data['website']:"";
184
$this->user->profile->gender = (array_key_exists('gender',$data))?$data['gender']:"";
185
+ $this->user->profile->language = (array_key_exists('locale',$data))?$data['locale']:"";
186
+ $this->user->profile->description = (array_key_exists('about',$data))?$data['about']:"";
187
$this->user->profile->email = (array_key_exists('email',$data))?$data['email']:"";
188
$this->user->profile->emailVerified = (array_key_exists('email',$data))?$data['email']:"";
189
$this->user->profile->region = (array_key_exists("hometown",$data)&&array_key_exists("name",$data['hometown']))?$data['hometown']["name"]:"";
190
+
191
+ if(!empty($this->user->profile->region )){
192
+ $regionArr = explode(',',$this->user->profile->region );
193
+ if(count($regionArr) > 1){
194
+ $this->user->profile->city = trim($regionArr[0]);
195
+ $this->user->profile->country = trim($regionArr[1]);
196
+ }
197
+ }
198
+
199
if( array_key_exists('birthday',$data) ) {
200
list($birthday_month, $birthday_day, $birthday_year) = explode( "/", $data['birthday'] );
201
207
return $this->user->profile;
208
}
209
210
+ /**
211
+ * Attempt to retrieve the url to the cover image given the coverInfoURL
212
+ *
213
+ * @param string $coverInfoURL coverInfoURL variable
214
+ * @retval string url to the cover image OR blank string
215
+ */
216
+ function getCoverURL($coverInfoURL)
217
+ {
218
+ try {
219
+ $headers = get_headers($coverInfoURL);
220
+ if(substr($headers[0], 9, 3) != "404") {
221
+ $coverOBJ = json_decode(file_get_contents($coverInfoURL));
222
+ if(array_key_exists('cover', $coverOBJ)) {
223
+ return $coverOBJ->cover->source;
224
+ }
225
+ }
226
+ } catch (Exception $e) { }
227
+
228
+ return "";
229
+ }
230
+
231
/**
232
* load the user contacts
233
*/
234
function getUserContacts()
235
{
236
+ $apiCall = '?fields=link,name';
237
+ $returnedContacts = array();
238
+ $pagedList = false;
239
+
240
+ do {
241
+ try{
242
+ $response = $this->api->api('/me/friends' . $apiCall);
243
+ }
244
+ catch( FacebookApiException $e ){
245
+ throw new Exception( 'User contacts request failed! {$this->providerId} returned an error: $e' );
246
+ }
247
+
248
+ // Prepare the next call if paging links have been returned
249
+ if (array_key_exists('paging', $response) && array_key_exists('next', $response['paging'])) {
250
+ $pagedList = true;
251
+ $next_page = explode('friends', $response['paging']['next']);
252
+ $apiCall = $next_page[1];
253
+ }
254
+ else{
255
+ $pagedList = false;
256
+ }
257
+
258
+ // Add the new page contacts
259
+ $returnedContacts = array_merge($returnedContacts, $response['data']);
260
}
261
+ while ($pagedList == true);
262
263
$contacts = ARRAY();
264
265
+ foreach( $returnedContacts as $item ){
266
$uc = new Hybrid_User_Contact();
267
268
$uc->identifier = (array_key_exists("id",$item))?$item["id"]:"";
269
$uc->displayName = (array_key_exists("name",$item))?$item["name"]:"";
270
+ $uc->profileURL = (array_key_exists("link",$item))?$item["link"]:"https://www.facebook.com/profile.php?id=" . $uc->identifier;
271
$uc->photoURL = "https://graph.facebook.com/" . $uc->identifier . "/picture?width=150&height=150";
272
273
$contacts[] = $uc;
276
return $contacts;
277
}
278
279
+ /**
280
+ * update user status
281
+ *
282
+ * @param string $pageid (optional) User page id
283
+ */
284
+ function setUserStatus( $status, $pageid = null )
285
+ {
286
+ if( !is_array( $status ) ){
287
+ $status = array( 'message' => $status );
288
+ }
289
+
290
+ if( is_null( $pageid ) ){
291
+ $pageid = 'me';
292
+
293
+ // if post on page, get access_token page
294
+ }else{
295
+ $access_token = null;
296
+ foreach( $this->getUserPages( true ) as $p ){
297
+ if( isset( $p[ 'id' ] ) && intval( $p['id'] ) == intval( $pageid ) ){
298
+ $access_token = $p[ 'access_token' ];
299
+ break;
300
+ }
301
+ }
302
+
303
+ if( is_null( $access_token ) ){
304
+ throw new Exception( "Update user page failed, page not found or not writable!" );
305
+ }
306
+
307
+ $status[ 'access_token' ] = $access_token;
308
+ }
309
+
310
+ try{
311
+ $response = $this->api->api( '/' . $pageid . '/feed', 'post', $status );
312
+ }
313
+ catch( FacebookApiException $e ){
314
+ throw new Exception( "Update user status failed! {$this->providerId} returned an error: $e" );
315
+ }
316
+
317
+ return $response;
318
+ }
319
320
321
+ /**
322
+ * get user status
323
+ */
324
+ function getUserStatus( $postid )
325
+ {
326
+ try{
327
+ $postinfo = $this->api->api( "/" . $postid );
328
+ }
329
catch( FacebookApiException $e ){
330
+ throw new Exception( "Cannot retrieve user status! {$this->providerId} returned an error: $e" );
331
}
332
+
333
+ return $postinfo;
334
+ }
335
+
336
+
337
+ /**
338
+ * get user pages
339
+ */
340
+ function getUserPages( $writableonly = false )
341
+ {
342
+ if( ( isset( $this->config[ 'scope' ] ) && strpos( $this->config[ 'scope' ], 'manage_pages' ) === false ) || ( !isset( $this->config[ 'scope' ] ) && strpos( $this->scope, 'manage_pages' ) === false ) )
343
+ throw new Exception( "User status requires manage_page permission!" );
344
+
345
+ try{
346
+ $pages = $this->api->api( "/me/accounts", 'get' );
347
+ }
348
+ catch( FacebookApiException $e ){
349
+ throw new Exception( "Cannot retrieve user pages! {$this->providerId} returned an error: $e" );
350
+ }
351
+
352
+ if( !isset( $pages[ 'data' ] ) ){
353
+ return array();
354
+ }
355
+
356
+ if( !$writableonly ){
357
+ return $pages[ 'data' ];
358
+ }
359
+
360
+ $wrpages = array();
361
+ foreach( $pages[ 'data' ] as $p ){
362
+ if( isset( $p[ 'perms' ] ) && in_array( 'CREATE_CONTENT', $p[ 'perms' ] ) ){
363
+ $wrpages[] = $p;
364
+ }
365
+ }
366
+
367
+ return $wrpages;
368
+ }
369
370
/**
371
* load the user latest activity
hybridauth/Hybrid/Providers/Foursquare.php CHANGED
@@ -32,7 +32,7 @@ class Hybrid_Providers_Foursquare extends Hybrid_Provider_Model_OAuth2
32
*/
33
function getUserProfile()
34
{
35
- $data = $this->api->api( "users/self" );
36
37
if ( ! isset( $data->response->user->id ) ){
38
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
32
*/
33
function getUserProfile()
34
{
35
+ $data = $this->api->api( "users/self", "GET", array( "v" => "20120610" ) );
36
37
if ( ! isset( $data->response->user->id ) ){
38
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
hybridauth/Hybrid/Providers/GitHub.php CHANGED
@@ -35,7 +35,7 @@ class Hybrid_Providers_GitHub extends Hybrid_Provider_Model_OAuth2
35
$data = $this->api->api( "user" );
36
37
if ( ! isset( $data->id ) ){
38
- throw new Exception( "User profile request failed! {$this->providerId} returned an invalide response.", 6 );
39
}
40
41
$this->user->profile->identifier = @ $data->id;
@@ -51,6 +51,22 @@ class Hybrid_Providers_GitHub extends Hybrid_Provider_Model_OAuth2
51
$this->user->profile->displayName = @ $data->login;
52
}
53
54
return $this->user->profile;
55
}
56
}
35
$data = $this->api->api( "user" );
36
37
if ( ! isset( $data->id ) ){
38
+ throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
39
}
40
41
$this->user->profile->identifier = @ $data->id;
51
$this->user->profile->displayName = @ $data->login;
52
}
53
54
+ // request user emails from github api
55
+ if( ! $data->email ){
56
+ try{
57
+ $emails = $this->api->api("user/emails");
58
+
59
+ // fail gracefully, and let apps collect the email if not present
60
+ if (is_array($emails) && !empty($emails[0]->email))
61
+ {
62
+ $this->user->profile->email = $emails[0]->email;
63
+ }
64
+ }
65
+ catch( GithubApiException $e ){
66
+ throw new Exception( "User email request failed! {$this->providerId} returned an error: $e", 6 );
67
+ }
68
+ }
69
+
70
return $this->user->profile;
71
}
72
}
hybridauth/Hybrid/Providers/Goodreads.php CHANGED
@@ -34,36 +34,36 @@ class Hybrid_Providers_Goodreads extends Hybrid_Provider_Model_OAuth1
34
{
35
// in case we get authorize=0
36
if ( ! isset($_REQUEST['oauth_token']) || ( isset( $_REQUEST['authorize'] ) && $_REQUEST['authorize'] == "0" ) ){
37
- throw new Exception( "Authentification failed! The user denied your request.", 5 );
38
}
39
40
$oauth_verifier = @ $_REQUEST['oauth_token'];
41
42
if ( !$oauth_verifier ){
43
- throw new Exception( "Authentification failed! {$this->providerId} returned an invalid oauth verifier.", 5 );
44
}
45
46
// request an access token
47
$tokens = $this->api->accessToken( $oauth_verifier );
48
49
- // access tokens as recived from provider
50
$this->access_tokens_raw = $tokens;
51
52
// check the last HTTP status code returned
53
if ( $this->api->http_code != 200 ){
54
- throw new Exception( "Authentification failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ), 5 );
55
}
56
57
// we should have an access_token, or else, something has gone wrong
58
if ( ! isset( $tokens["oauth_token"] ) ){
59
- throw new Exception( "Authentification failed! {$this->providerId} returned an invalid access token.", 5 );
60
}
61
62
- // we no more need to store requet tokens
63
$this->deleteToken( "request_token" );
64
$this->deleteToken( "request_token_secret" );
65
66
- // sotre access_token for later user
67
$this->token( "access_token" , $tokens['oauth_token'] );
68
$this->token( "access_token_secret" , $tokens['oauth_token_secret'] );
69
34
{
35
// in case we get authorize=0
36
if ( ! isset($_REQUEST['oauth_token']) || ( isset( $_REQUEST['authorize'] ) && $_REQUEST['authorize'] == "0" ) ){
37
+ throw new Exception( "Authentication failed! The user denied your request.", 5 );
38
}
39
40
$oauth_verifier = @ $_REQUEST['oauth_token'];
41
42
if ( !$oauth_verifier ){
43
+ throw new Exception( "Authentication failed! {$this->providerId} returned an invalid oauth verifier.", 5 );
44
}
45
46
// request an access token
47
$tokens = $this->api->accessToken( $oauth_verifier );
48
49
+ // access tokens as received from provider
50
$this->access_tokens_raw = $tokens;
51
52
// check the last HTTP status code returned
53
if ( $this->api->http_code != 200 ){
54
+ throw new Exception( "Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ), 5 );
55
}
56
57
// we should have an access_token, or else, something has gone wrong
58
if ( ! isset( $tokens["oauth_token"] ) ){
59
+ throw new Exception( "Authentication failed! {$this->providerId} returned an invalid access token.", 5 );
60
}
61
62
+ // we no more need to store request tokens
63
$this->deleteToken( "request_token" );
64
$this->deleteToken( "request_token_secret" );
65
66
+ // store access_token for later user
67
$this->token( "access_token" , $tokens['oauth_token'] );
68
$this->token( "access_token_secret" , $tokens['oauth_token_secret'] );
69
hybridauth/Hybrid/Providers/Google.php CHANGED
@@ -2,7 +2,7 @@
2
/*!
3
* HybridAuth
4
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
5
- * (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
6
*/
7
8
/**
@@ -12,8 +12,11 @@
12
*/
13
class Hybrid_Providers_Google extends Hybrid_Provider_Model_OAuth2
14
{
15
// default permissions
16
- public $scope = "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.google.com/m8/feeds/";
17
18
/**
19
* IDp wrappers initializer
@@ -25,7 +28,13 @@ class Hybrid_Providers_Google extends Hybrid_Provider_Model_OAuth2
25
// Provider api end-points
26
$this->api->authorize_url = "https://accounts.google.com/o/oauth2/auth";
27
$this->api->token_url = "https://accounts.google.com/o/oauth2/token";
28
- $this->api->token_info_url = "https://www.googleapis.com/oauth2/v1/tokeninfo";