How can I authenticate users from rails using authlogic?

On my system, users register through the rails website. I have to authenticate users from a user application server written in ruby.

error messsage:

You must activate the Authlogic::Session::Base.controller with a controller object before creating objects (Authlogic::Session::Activation::NotActivatedError)
+5
source share
3 answers

From: http://rdoc.info/projects/binarylogic/authlogic

require "authlogic/test_case" # include at the top of test_helper.rb
setup :activate_authlogic # run before tests are executed
UserSession.create(users(:whomever)) # logs a user in
+6
source

Try it first:

Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
+5
source

I circumvented this error using user239662 advice (it was not clear to me, so I am posting this solution). My definition of cucumber pitch now looks like this:

When /^I am logged in as "(.*)"$/ do |user|
  @current_user = User.make!(:username => user)
  require 'authlogic/test_case'
  activate_authlogic
  @current_session = UserSession.create!(@current_user)
end
0
source

All Articles