Acts_as_authenticated user acount/login

Hi,

I followed most of the book ROR e-Commerce and am using
acts_as_autheniticated plugin.
When I created the user object, I created it using:
$ script/generate authenticated user account

Then I decided that instead of account/login I wanted it to be admin/
login – so I eliminated the account from the equation.

My admin controller says if the user is not logged in, redirect to
admin/login but instead I get a routing error:

no route found to match “/account/login” with {:method=>:get}

I went through all my controller files and plugin files and can’t find
where it still sets the route as account/login.

Here is my admin_controller.rb:
class AdminController < Admin::BaseController
observer :user_observer

Be sure to include AuthenticationSystem in Application Controller

instead

include AuthenticatedSystem

If you want “remember me” functionality, add this before_filter to

Application Controller
before_filter :login_from_cookie

say something nice, you goof! something sweet.

def index
@page_title = “Admin Area”
redirect_to(:controller => ‘/admin’, :action => ‘login’) unless
logged_in? || User.count > 0
end

def login
return unless request.post?
self.current_user = User.authenticate(params[:login],
params[:password])
if logged_in?
if params[:remember_me] == “1”
self.current_user.remember_me
cookies[:auth_token] = { :value =>
self.current_user.remember_token , :expires =>
self.current_user.remember_token_expires_at }
end
redirect_back_or_default(:controller => ‘/admin’, :action =>
‘index’)
flash[:notice] = “Logged in successfully”
end
flash.now[:notice] = “Incorrect login!”
end

def logout
self.current_user.forget_me if logged_in?
cookies.delete :auth_token
reset_session
flash[:notice] = “You have been logged out.”
redirect_back_or_default(:controller => ‘/admin’, :action =>
‘login’)
end

And my base_controller.rb;
class Admin::BaseController < ApplicationController
before_filter :login_required
end

and vendor/plugins/acts_as_authenticated/generators/templates/
authenticated_system.rb:

def login_required
username, passwd = get_auth_data
self.current_<%= file_name %> ||= <%= class_name
%>.authenticate(username, passwd) || :false if username && passwd
logged_in? && authorized? ? true : access_denied
end

I went through every file and just cant find where it still sets the
wrong route.
Please help.

Elle

Found my problem
lib/authenticated_system.rb:
def access_denied
respond_to do |accepts|
accepts.html do
store_location
redirect_to :controller => ‘/admin’, :action => ‘login’
end
accepts.xml do
headers[“Status”] = “Unauthorized”
headers[“WWW-Authenticate”] = %(Basic realm=“Web Password”)
render :text => “Could’t authenticate you”, :status => ‘401
Unauthorized’
end
end
false
end

But now, I get this arror message:
“Too many redirects occurred trying to open “http://localhost:3000/
admin/login”. This might occur if you open a page that is redirected
to open another page which then is redirected to open the original
page.”

Would you know what is the problem now?
Help??

Elle

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs