vBulletin login system
Hi, I'm working on a system which will let Auth use the user table of a vBulletin forum.
The idea behind it is simple enough, you just need to point the User model at the forum's user table, modify the hashPasswords() function to take into account the way that vBulletin hashes passwords, and - in theory - jobs a good'en.
I've managed to get so far by myself, but it still doesn't seem to be working, so I was hoping that someone here might be able to fill in the blanks for me.
First, here is the database schema for the vBulletin forum:
CREATE TABLE IF NOT EXISTS `vb_user` (
`userid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`usergroupid` smallint(5) unsigned NOT NULL DEFAULT '0',
`membergroupids` char(250) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`displaygroupid` smallint(5) unsigned NOT NULL DEFAULT '0',
`username` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`password` char(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`passworddate` date NOT NULL DEFAULT '0000-00-00',
`email` char(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`styleid` smallint(5) unsigned NOT NULL DEFAULT '0',
`parentemail` char(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`homepage` char(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`icq` char(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`aim` char(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`yahoo` char(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`msn` char(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`skype` char(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`showvbcode` smallint(5) unsigned NOT NULL DEFAULT '0',
`showbirthday` smallint(5) unsigned NOT NULL DEFAULT '2',
`usertitle` char(250) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`customtitle` smallint(6) NOT NULL DEFAULT '0',
`joindate` int(10) unsigned NOT NULL DEFAULT '0',
`daysprune` smallint(6) NOT NULL DEFAULT '0',
`lastvisit` int(10) unsigned NOT NULL DEFAULT '0',
`lastactivity` int(10) unsigned NOT NULL DEFAULT '0',
`lastpost` int(10) unsigned NOT NULL DEFAULT '0',
`lastpostid` int(10) unsigned NOT NULL DEFAULT '0',
`posts` int(10) unsigned NOT NULL DEFAULT '0',
`reputation` int(11) NOT NULL DEFAULT '10',
`reputationlevelid` int(10) unsigned NOT NULL DEFAULT '1',
`timezoneoffset` char(4) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`pmpopup` smallint(6) NOT NULL DEFAULT '0',
`avatarid` smallint(6) NOT NULL DEFAULT '0',
`avatarrevision` int(10) unsigned NOT NULL DEFAULT '0',
`profilepicrevision` int(10) unsigned NOT NULL DEFAULT '0',
`sigpicrevision` int(10) unsigned NOT NULL DEFAULT '0',
`options` int(10) unsigned NOT NULL DEFAULT '33554447',
`birthday` char(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`birthday_search` date NOT NULL DEFAULT '0000-00-00',
`maxposts` smallint(6) NOT NULL DEFAULT '-1',
`startofweek` smallint(6) NOT NULL DEFAULT '1',
`ipaddress` char(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`referrerid` int(10) unsigned NOT NULL DEFAULT '0',
`languageid` smallint(5) unsigned NOT NULL DEFAULT '0',
`emailstamp` int(10) unsigned NOT NULL DEFAULT '0',
`threadedmode` smallint(5) unsigned NOT NULL DEFAULT '0',
`autosubscribe` smallint(6) NOT NULL DEFAULT '-1',
`pmtotal` smallint(5) unsigned NOT NULL DEFAULT '0',
`pmunread` smallint(5) unsigned NOT NULL DEFAULT '0',
`salt` char(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`ipoints` int(10) unsigned NOT NULL DEFAULT '0',
`infractions` int(10) unsigned NOT NULL DEFAULT '0',
`warnings` int(10) unsigned NOT NULL DEFAULT '0',
`infractiongroupids` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`infractiongroupid` smallint(5) unsigned NOT NULL DEFAULT '0',
`adminoptions` int(10) unsigned NOT NULL DEFAULT '0',
`profilevisits` int(10) unsigned NOT NULL DEFAULT '0',
`friendcount` int(10) unsigned NOT NULL DEFAULT '0',
`friendreqcount` int(10) unsigned NOT NULL DEFAULT '0',
`vmunreadcount` int(10) unsigned NOT NULL DEFAULT '0',
`vmmoderatedcount` int(10) unsigned NOT NULL DEFAULT '0',
`socgroupinvitecount` int(10) unsigned NOT NULL DEFAULT '0',
`socgroupreqcount` int(10) unsigned NOT NULL DEFAULT '0',
`pcunreadcount` int(10) unsigned NOT NULL DEFAULT '0',
`pcmoderatedcount` int(10) unsigned NOT NULL DEFAULT '0',
`gmmoderatedcount` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`userid`),
KEY `usergroupid` (`usergroupid`),
KEY `username` (`username`),
KEY `birthday` (`birthday`,`showbirthday`),
KEY `birthday_search` (`birthday_search`),
KEY `referrerid` (`referrerid`)
)Most of this can be ignored, the only really important fields (for the moment at least) are userid, username, password and salt.
To get started I've modified the user.php model to use the forum table rather than the cake one, and created the function hashPasswords() method according to vBulletin rules
class User extends AppModel {
var $name = 'User';
var $useDbConfig = 'forum';
var $useTable = 'user';
var $primaryKey = 'userid';
function hashPasswords($data)
{
$user_salt = ')Mc';
$data['User']['password'] = md5(md5($data['User']['password']) . $user_salt);
return $data;
}
}Next I've added the required data to the app_controller.php in the beforeFilter() method so that it knows what fields, etc.. to use
class AppController extends Controller {
var $helpers = array('Html', 'Form', 'Javascript', 'Time');
var $components = array('Auth', 'Session', 'Email');
function beforeFilter()
{
//Set up Auth Component settings
$this->Auth->loginAction = array('admin' => false, 'controller' => 'users', 'action' => 'login');
$this->Auth->loginRedirect = '/';
$this->Auth->logoutRedirect = '/';
$this->Auth->loginError = 'Invalid username / password combination. Please try again.';
$this->Auth->authError = 'Sorry, you do not have the correct permissions to access this page.';
$this->Auth->allow(array('display')); // give access to homepage
$this->Auth->authorize = 'controller';
$this->Auth->authenticate = ClassRegistry::init('User'); // tells Auth to use the User hashPasswords() method
}
function isAuthorized()
{
return true;
}
}Then it's just a case of business as usual, with the blank login() method in the users_controller.php file.
The problem I have is that when I log in, it's acting as if I've succeeded to log in (I know that the query to the database is succeeding), but I'm not actually logged in.
Any ideas?
Asked by TheWorldofDan, on 9/11/09
1 Answer
Your Answer
You can use Creole Wiki Syntax to format your text.
Tagged with
Rating
0
Viewed
4559 times
Last Activity
on 29/1/10