Skip to content

Commit

Permalink
Properly propagata realname to session vars, fixes #156
Browse files Browse the repository at this point in the history
  • Loading branch information
garvinhicking committed May 28, 2014
1 parent e52c8e1 commit a3103ea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
4 changes: 4 additions & 0 deletions serendipity_event_openid/ChangeLog
@@ -1,3 +1,7 @@
Version 1.2

* Fixed missing "realname" attribute in authentication

Version 1.0 (brockhaus)
---------------------------------
* Delegation: Configure what OpenID version the provider is supporting (Version 1 or 2 or both)
Expand Down
20 changes: 11 additions & 9 deletions serendipity_event_openid/common.inc.php
@@ -1,4 +1,4 @@
<?php #
<?php # $Id$

// Probe for a language include with constants. Still include defines later on, if some constants were missing
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
Expand All @@ -13,7 +13,7 @@ function escape($message) {

class serendipity_common_openid {

static function redir_openidserver($openid_url, $store_path, $wfFlag=1) {
function redir_openidserver($openid_url, $store_path, $wfFlag=1) {
global $serendipity;

$path_extra = dirname(__FILE__).DIRECTORY_SEPARATOR.'PHP-openid/';
Expand Down Expand Up @@ -57,6 +57,7 @@ static function redir_openidserver($openid_url, $store_path, $wfFlag=1) {
static function reauth_openid() {
global $serendipity;
if (isset($_SESSION['serendipityOpenID']) && $_SESSION['serendipityOpenID']) {
$serendipity['serendipityRealname'] = $_SESSION['serendipityRealname'];
$serendipity['serendipityUser'] = $_SESSION['serendipityUser'];
$serendipity['serendipityPassword'] = $_SESSION['serendipityPassword'];
$serendipity['serendipityEmail'] = $_SESSION['serendipityEmail'];
Expand All @@ -70,7 +71,7 @@ static function reauth_openid() {
return false;
}

static function authenticate_openid($getData, $store_path, $returnData = false) {
function authenticate_openid($getData, $store_path, $returnData = false) {
global $serendipity;

$trust_root = $serendipity['baseURL'] . 'serendipity_admin.php';
Expand Down Expand Up @@ -133,7 +134,7 @@ static function authenticate_openid($getData, $store_path, $returnData = false)
return array('realname'=>$realname, 'email'=>$email, 'openID'=>$openid);
}
$password = md5($openid);
$query = "SELECT DISTINCT a.email, a.authorid, a.userlevel, a.right_publish
$query = "SELECT DISTINCT a.email, a.authorid, a.userlevel, a.right_publish, a.realname
FROM
{$serendipity['dbPrefix']}authors AS a, {$serendipity['dbPrefix']}openid_authors AS oa
WHERE
Expand All @@ -143,13 +144,14 @@ static function authenticate_openid($getData, $store_path, $returnData = false)
if (is_array($row)) {
serendipity_setCookie('old_session', session_id());
serendipity_setAuthorToken();
$_SESSION['serendipityUser'] = $serendipity['serendipityUser'] = $realname;
$_SESSION['serendipityUser'] = $serendipity['serendipityUser'] = $row['realname'];
$_SESSION['serendipityPassword'] = $serendipity['serendipityPassword'] = $password;
$_SESSION['serendipityEmail'] = $serendipity['serendipityEmail'] = $email;
$_SESSION['serendipityAuthorid'] = $serendipity['authorid'] = $row['authorid'];
$_SESSION['serendipityUserlevel'] = $serendipity['serendipityUserlevel'] = $row['userlevel'];
$_SESSION['serendipityAuthedUser'] = $serendipity['serendipityAuthedUser'] = true;
$_SESSION['serendipityRightPublish']= $serendipity['serendipityRightPublish'] = $row['right_publish'];
$_SESSION['serendipityRealname'] = $serendipity['serendipityRealname'] = $row['realname'];
$_SESSION['serendipityOpenID'] = true;
serendipity_load_configuration($serendipity['authorid']);
return true;
Expand All @@ -161,7 +163,7 @@ static function authenticate_openid($getData, $store_path, $returnData = false)
return false;
}

static function getOpenID($userID, $checkExist=false) {
function getOpenID($userID, $checkExist=false) {
global $serendipity;
$q = "SELECT openid_url, authorid FROM {$serendipity['dbPrefix']}openid_authors WHERE authorid = " . (int)$userID;
$author = serendipity_db_query($q, true);
Expand All @@ -175,7 +177,7 @@ static function getOpenID($userID, $checkExist=false) {
return '';
}

static function updateOpenID($openid_url, $authorID) {
function updateOpenID($openid_url, $authorID) {
global $serendipity;

if (!is_array(serendipity_db_query("SELECT username FROM {$serendipity['dbPrefix']}openid_authors LIMIT 1", true, 'both', false, false, false, true))) {
Expand All @@ -201,7 +203,7 @@ static function updateOpenID($openid_url, $authorID) {
return ($retVal===true)?true:false;
}

static function load_account_selectbox() {
function load_account_selectbox() {
global $serendipity;

$query = "SELECT DISTINCT a.realname, a.username, oa.openid_url
Expand Down Expand Up @@ -229,7 +231,7 @@ static function load_account_selectbox() {
return $result;
}

static function loginform($url, $hidden = array(), $useAutorSelector = true) {
function loginform($url, $hidden = array(), $useAutorSelector = true) {
global $serendipity;

$imgopenid = $serendipity['baseURL'] . 'index.php?/plugin/openid.png';
Expand Down
2 changes: 1 addition & 1 deletion serendipity_event_openid/serendipity_event_openid.php
Expand Up @@ -13,7 +13,7 @@ function introspect(&$propbag)
$propbag->add('description', PLUGIN_OPENID_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Grischa Brockhaus, Rob Richards');
$propbag->add('version', '1.1');
$propbag->add('version', '1.2');
$propbag->add('requirements', array(
'serendipity' => '1.2',
'smarty' => '2.6.7',
Expand Down

0 comments on commit a3103ea

Please sign in to comment.