Method: ActionController::Base#vbulletin_login

Defined in:
lib/vbulletin_rails/core_ext.rb

#vbulletin_login(options = {}) ⇒ Object (private)

Signs in VBulletin user, when correct email/username and password are provided It also sets session[:vbulletin_userid] to VBulletinRails::User#userid which can be checked in your application if needed.

 :email => 'user@example.com', :password => 'user password' # signs in by user email
 :username => 'username',      :password => 'user password' # signs in by username


126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/vbulletin_rails/core_ext.rb', line 126

def  options = {}
  vb_user = nil
  vb_user = VBulletinRails::User.find_by_email(options[:email]) if options[:email]
  vb_user = VBulletinRails::User.find_by_username(options[:username]) if options[:username] and vb_user.blank?

  return false unless vb_user and vb_user.authenticate(options[:password])

  vb_session = VBulletinRails::Session.set(options.merge({:request => request, :user => vb_user}))
  session[:vbulletin_userid] = vb_user.userid
  cookies[:bb_lastactivity], cookies[:bb_lastvisit] = vb_session.update_timestamps
  cookies[:bb_sessionhash] = vb_session.sessionhash

  set_permanent_vbulletin_session_for vb_user if options[:permanent]

  return vb_user
end

Comments