[geeklog-cvs] geeklog: Cleaned up OAuth service resynch. Added in an extra err...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Fri Jan 21 14:33:41 EST 2011
changeset 8057:b59d5fd75210
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/b59d5fd75210
user: Tom <websitemaster at cogeco.net>
date: Fri Jan 21 14:32:52 2011 -0500
description:
Cleaned up OAuth service resynch. Added in an extra error message.
diffstat:
language/english.php | 1 +
language/english_utf-8.php | 1 +
public_html/usersettings.php | 64 +++++++++++++++----------------------------
3 files changed, 24 insertions(+), 42 deletions(-)
diffs (142 lines):
diff -r a1229c1e36d0 -r b59d5fd75210 language/english.php
--- a/language/english.php Thu Jan 20 14:26:23 2011 +0000
+++ b/language/english.php Fri Jan 21 14:32:52 2011 -0500
@@ -1270,6 +1270,7 @@
112 => 'Certification has been canceled.',
113 => 'Your account has been created successfully. {site_url}',
114 => 'Your re-synch with your remote account has failed but your other account information has been successfully saved.',
+ 115 => 'Remote service has been disabled.',
400 => 'Not all required fields have been passed validation', // Error codes in the 400 range reserved for CUSTOM membership
401 => 'Please enter Fullname'
);
diff -r a1229c1e36d0 -r b59d5fd75210 language/english_utf-8.php
--- a/language/english_utf-8.php Thu Jan 20 14:26:23 2011 +0000
+++ b/language/english_utf-8.php Fri Jan 21 14:32:52 2011 -0500
@@ -1269,6 +1269,7 @@
112 => 'Certification has been canceled.',
113 => 'Your account has been created successfully. {site_url}',
114 => 'Your re-synch with your remote account has failed but your other account information has been successfully saved.',
+ 115 => 'Remote service has been disabled.',
400 => 'Not all required fields have been passed validation', // Error codes in the 400 range reserved for CUSTOM membership
401 => 'Please enter Fullname'
);
diff -r a1229c1e36d0 -r b59d5fd75210 public_html/usersettings.php
--- a/public_html/usersettings.php Thu Jan 20 14:26:23 2011 +0000
+++ b/public_html/usersettings.php Fri Jan 21 14:32:52 2011 -0500
@@ -1108,49 +1108,34 @@
$msg = 5;
// Re Sync data if needed
if (isset($A['resynch'])) {
- $query[] = '';
- // ReSynch
if ($_CONF['user_login_method']['oauth'] && (strpos($_USER['remoteservice'], 'oauth.') === 0)) {
$modules = SEC_collectRemoteOAuthModules();
$active_service = (count($modules) == 0) ? false : in_array(substr($_USER['remoteservice'], 6), $modules);
if (!$active_service) {
$status = -1;
- $msg = 114; // Account saved but re-synch failed
+ $msg = 115; // Remote service has been disabled.
} else {
- $callback_url = $_CONF['site_url'] . '/usersettings.php?mode=synch&oauth_login=' . $service;
-
+ // Send request to OAuth Service for user information
require_once $_CONF['path_system'] . 'classes/oauthhelper.class.php';
$consumer = new OAuthConsumer($service);
- $callback_query_string = $consumer->getCallback_query_string();
- $cancel_query_string = $consumer->getCancel_query_string();
-
- if (!isset($query[$callback_query_string]) && (empty($cancel_query_string) || !isset($query[$cancel_query_string]))) {
- $url = $consumer->find_identity_info($callback_url, $query);
- if (empty($url)) {
- $msg = 110;
- } else {
- header('Location: ' . $url);
- exit;
- }
- } elseif (isset($query[$callback_query_string])) {
- $oauth_userinfo = $consumer->sreq_userinfo_response($query);
- if (empty($oauth_userinfo)) {
- $msg = 111;
- } else {
- $consumer->doSynch($oauth_userinfo);
- }
- } elseif (!empty($cancel_query_string) && isset($query[$cancel_query_string])) {
- $msg = 112;
+
+ $query[] = '';
+ $callback_url = $_CONF['site_url'] . '/usersettings.php?mode=synch&oauth_login=' . $service;
+
+ $url = $consumer->find_identity_info($callback_url, $query);
+ if (empty($url)) {
+ $msg = 110; // Can not get URL for authentication.'
} else {
- $msg = 91;
+ header('Location: ' . $url);
+ exit;
}
}
}
if ($msg != 5) {
- $msg = 114; // Account saved but re-synch failed
+ $msg = 114; // Account saved but re-synch failed.
}
}
@@ -1402,18 +1387,20 @@
break;
case 'synch':
- $msg = 5;
- $query[] = '';
+ // This mode is the result of a callback from an OAuth service. The user has made a request to resynch their Geeklog user account with the OAuth service they used to login with.
if ($_CONF['user_login_method']['oauth'] && (strpos($_USER['remoteservice'], 'oauth.') === 0) && isset($_GET['oauth_login'])) {
+ $msg = 5;
+ $query[] = '';
+
// Here we go with the handling of OAuth authentification
$modules = SEC_collectRemoteOAuthModules();
$active_service = (count($modules) == 0) ? false : in_array(substr($_GET['oauth_login'], 6), $modules);
if (!$active_service) {
$status = -1;
- $msg = 114;
+ $msg = 114; // Your re-synch with your remote account has failed but your other account information has been successfully saved.
} else {
$query = array_merge($_GET, $_POST);
- $service = $_GET['oauth_login']; // DB_getItem ($_TABLES['users'], 'remoteservice', "uid = {$_USER['uid']}");
+ $service = $_GET['oauth_login'];
$callback_url = $_CONF['site_url'] . '/usersettings.php?mode=synch&oauth_login=' . $service;
require_once $_CONF['path_system'] . 'classes/oauthhelper.class.php';
@@ -1423,25 +1410,18 @@
$cancel_query_string = $consumer->getCancel_query_string();
if (!isset($query[$callback_query_string]) && (empty($cancel_query_string) || !isset($query[$cancel_query_string]))) {
- $url = $consumer->find_identity_info($callback_url, $query);
- if (empty($url)) {
- $msg = 110;
- } else {
- // header('Location: ' . $url);
- // exit;
- $msg = 110;
- }
+ $msg = 114; // Your re-synch with your remote account has failed but your other account information has been successfully saved.
} elseif (isset($query[$callback_query_string])) {
$oauth_userinfo = $consumer->sreq_userinfo_response($query);
if (empty($oauth_userinfo)) {
- $msg = 111;
+ $msg = 111; // Authentication error.
} else {
$consumer->doSynch($oauth_userinfo);
}
} elseif (!empty($cancel_query_string) && isset($query[$cancel_query_string])) {
- $msg = 112;
+ $msg = 112; // Certification has been canceled.
} else {
- $msg = 91;
+ $msg = 91; // You specified an invalid identity URL.
}
}
More information about the geeklog-cvs
mailing list