From abe9538c9755746598ec8d8ac8cd075082f4f2de Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 27 Feb 2007 04:25:41 +0000 Subject: [PATCH] r1425: - The new vBulletin authentication API now works - If you define the USE_DEFAULT_AUTH_METHOD as 1 then Bugdar will ignore any authentication system set and will just the Bugdar database --- includes/auth/auth_vbulletin.php | 37 +++++++++++++++++++++++--------- includes/init.php | 4 ++++ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/includes/auth/auth_vbulletin.php b/includes/auth/auth_vbulletin.php index ca36d79..e0e5d8c 100644 --- a/includes/auth/auth_vbulletin.php +++ b/includes/auth/auth_vbulletin.php @@ -40,7 +40,7 @@ class AuthenticationVbulletin extends Authentication * This is the vBulletin license key that you can find in the Members' Area that is used in creating cookies * @var string */ - var $licenseKey = 'LXXXXXX'; + var $licenseKey = 'LXXXXXXX'; /** * The table prefix for all of vBulletin's tables @@ -51,7 +51,7 @@ class AuthenticationVbulletin extends Authentication // ################################################################### function _setupDatabase() { - $this->authDb =& new DB_MySQL($this->registry); + $this->authDb = new DB_MySQL($this->registry); $this->authDb->connect('VBULLETIN_DATABASE_SERVER', 'VB_DATABASE_USER', 'VB_DATABASE_PASSWORD', 'VBULLETIN_DATABASE_NAME', false); } @@ -107,15 +107,32 @@ class AuthenticationVbulletin extends Authentication // ################################################################### function _createBugdarUser() { - $user = new UserAPI($this->registry); // do not change this - $user->set('email', $this->authUser['email']); - $user->set('displayname', $this->authUser['name']); - $user->set('password', $this->authUser['password']); // some random value that won't be used for authentication - $user->set('usergroupid', 2); // default "Registered Users" group - $user->set('authid', $this->authUser['userid']); // This must be a COMPLETELY STATIC key that is found in the auth db that will permanently link Bugdar to the auth user - $user->insert(); // saves the user + $user = new UserAPI($this->registry); - return $user->values; // returns the newly created user array + // if the email already exists in the DB, it must be the same person so just hook up the authid + if ($check = $this->db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE email = '" . $this->db->escape_string($this->authUser['email']) . "'")) + { + $user->set('userid', $check['userid']); + $user->set_condition(); + $user->set('authid', $this->authUser['userid']); + $user->update(); + $user->fetch(); + + return $user->objdata; + } + else + { + $user = new UserAPI($this->registry); + $user->set('email', $this->authUser['email']); + $user->set('displayname', $this->authUser['username']); + $user->set('password', $this->authUser['password']); + $user->set('usergroupid', 2); + $user->set('authid', $this->authUser['userid']); + $user->set('timezone', $this->authUser['timezoneoffset']); + $user->insert(); + + return $user->values; + } } // ################################################################### diff --git a/includes/init.php b/includes/init.php index abb1cac..82b6a47 100755 --- a/includes/init.php +++ b/includes/init.php @@ -102,6 +102,10 @@ $bugsys->setAppVersion($bugsys->options['trackerversion']); // ################################################################### // load userinfo +if (defined('USE_DEFAULT_AUTH_METHOD') AND constant('USE_DEFAULT_AUTH_METHOD') == 1) +{ + $bugsys->options['authmethod'] = 'default'; +} require_once('./includes/auth/auth_' . $bugsys->options['authmethod'] . '.php'); $authClass = 'Authentication' . str_replace(' ', '', ucwords(str_replace('_', ' ', $bugsys->options['authmethod']))); -- 2.43.5