SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Non-Member
    Join Date
    Jul 2005
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Building a login system to work with vBulletin (PHP) forum software?

    I'm building a web site which needs to have a user login system, I don't want people to have to log in twice so need to use the data from the vbulletin user table. Being new to ruby this is quite a tricky task, what would be the best way to approach this?

  2. #2
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did this with PunBB - its surprisingly simple.

    First you need to create a new base model for your VBulletin models that establishes the DB connection:

    PHP Code:
    class VBulletin ActiveRecord::Base
      establish_connection 
    :vbulletin
    end 
    And in your database.yml file:

    PHP Code:
    vbulletin:
      
    adaptermysql
      username
    foo
      
    #etc.... 
    Now, create models for each of the tables you'll want to work with - unless vbulletin conforms to rails conventions (unlikely), you'll have to explicitly tell Rails the table name, and possibly the primary key col. Just make sure you extend the Vbulletin model so it inherits the connection.

    PHP Code:
    class User VBulletin
      set_table_name 
    "vbulletin_users_table"

      
    def self.authenticate(usernamepassword)
        
    #fill this in with something that works
      
    end
    end 
    In your controller:

    PHP Code:
    class LoginController ApplicationController
      def login
        
    @user User.authenticate(params[:username], params[:password])
        if @
    user
          
    # logged in
        
    end
      end
    end 
    Hope that helps.

  3. #3
    Non-Member
    Join Date
    Jul 2005
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's very useful, thanks. I haven't got far enough with Rails (read about 150 pages of agile web dev with rails!) yet to know about how to override defaults etc. so that will save me digging about.

    The other thing I just though of, is how to prevent the user having to login twice. It's going to be quite tricky to modify what session data is stored i would imagine and have both systems use the same session, so i wonder if ruby has anything like libcurl in php so i can just login to the vbulletin forum remotely when someone logs into the main site? Although that then raises the problem of when they login to the forum first they wont be logged into the main site, plus it would be a rather convoluted solution. Did you find a way around that?

  4. #4
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately I didn't find a way around that - the client was most concerned about not having to have two sets of credentials for two different systems - logging into each system separately wasn't as big a deal. I'd imagine any possible solution would be a messy one.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •