# Acts\_as\_authenticated user acount/login

**URL:** <https://www.ruby-forum.com/t/acts-as-authenticated-user-acount-login/114763>\
**Category:** Rails\
**Created:** [September 17, 2007, 1:25pm UTC](https://www.ruby-forum.com/t/acts-as-authenticated-user-acount-login/114763 "2007-09-17T13:25:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ccd318/32.png) [@elle](https://www.ruby-forum.com/u/elle)\
**Post date:** [September 17, 2007, 1:25pm UTC](https://www.ruby-forum.com/t/acts-as-authenticated-user-acount-login/114763/1 "2007-09-17T13:25:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![elle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ccd318/32.png) [@elle](https://www.ruby-forum.com/u/elle)\
**Post date:** [September 17, 2007, 1:25pm UTC](https://www.ruby-forum.com/t/acts-as-authenticated-user-acount-login/114763/2 "2007-09-17T13:25:42Z")

</div>

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/](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
