# Re: UserEngine Infinite Loop (Scott Walter)

**URL:** <https://www.ruby-forum.com/t/re-userengine-infinite-loop-scott-walter/101893>\
**Category:** Engines\
**Created:** [February 7, 2006, 6:43am UTC](https://www.ruby-forum.com/t/re-userengine-infinite-loop-scott-walter/101893 "2006-02-07T06:43:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rajesh\_GS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5e9695/32.png) [@Rajesh\_GS](https://www.ruby-forum.com/u/Rajesh_GS)\
**Post date:** [February 7, 2006, 6:43am UTC](https://www.ruby-forum.com/t/re-userengine-infinite-loop-scott-walter/101893/1 "2006-02-07T06:43:26Z")

</div>

Hi

I also experienced the same issue yesterday. is it has anything to do  
with store\_location ?

Thanks

---

<div class="post-metadata">

**Author:** ![Rajesh\_GS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5e9695/32.png) [@Rajesh\_GS](https://www.ruby-forum.com/u/Rajesh_GS)\
**Post date:** [February 16, 2006, 5:23pm UTC](https://www.ruby-forum.com/t/re-userengine-infinite-loop-scott-walter/101893/2 "2006-02-16T17:23:01Z")

</div>

Things to do when you ‘upgrade’ from the login engine to the user  
engine:

1. make SURE that you read the README properly. In particular, the  
before\_filter will change.
2. make sure that you’ve run the engine\_migrate and bootstrap rake  
tasks, so that you get the new tables and more importantly the  
guest/default user permissions!
3. bear in mind that any users you have created will NOT automatically  
be given roles, so they essentially will have no permissions at all.  
You’ll want to get creative solving that issue. A patch for the  
UserEngine rakefile which ‘upgrades’ existing users by assigning them  
all a particular Role will guarantee you a seat in Valhalla!
4. remove all sessions, just to be really clean about things.

In general, if you are finding that you get constantly redirected to  
the login page in an infinite loop, it means that you don’t have  
permission to get to it. This is either because:

a) the Guest role that the UserEngine assumes for all non-logged-in  
users doesn’t exist or doesn’t have the right permissions (there’s a  
handy UserEngine.check\_system\_roles method that can help you there)  
b) the user that you are logged in as doesn’t have any role which has  
permission for the login action.

Either way, it basically means your Roles setup is s-k-rewed and you  
need to check that you’ve followed all the steps. Again, a simple rake  
task (rake upgrade\_to\_user\_engine ??) might easily be written to take  
care of all these issues. The Norse Gods will welcome anyone brave  
enough to write this (or even create the Trac ticket such that I might  
get around to it).

james

On 2/7/06, Rajesh GS [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > trying to redirect to /user/login until Firefox decides to stop trying.
> > 
> > - → /user/login
> 
> * * *
> 
> engine-users mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org)

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![Rajesh\_GS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5e9695/32.png) [@Rajesh\_GS](https://www.ruby-forum.com/u/Rajesh_GS)\
**Post date:** [February 16, 2006, 9:22pm UTC](https://www.ruby-forum.com/t/re-userengine-infinite-loop-scott-walter/101893/3 "2006-02-16T21:22:03Z")

</div>

Hello,

I also had the same problem half an hour ago, when trying to add the  
UserEngine to the RikiEngine. And I was quite confident that I did  
everything correctly according to the README, as I saw the database  
populated as it was supposed to. Here is what my problem was, and how I  
solved it:

So, the problem was the same: The Infinite UserEngine Loop. When I  
looked in the log file (they are quite useful, sometimes), I saw the  
following:

Processing PagesController#login (for 127.0.0.1 at 2006-02-16 21:03:13)  
[GET]  
Parameters: {“action”=\>“login”, “controller”=\>“pages”,  
“book\_url\_name”=\>“user”}  
required\_perm is pages/login  
Permission Load (0.000000) SELECT DISTINCT permissions.\*  
FROM permissions, roles,  
permissions\_roles  
WHERE roles.name = ‘Guest’  
AND roles.id = permissions\_roles.role\_id  
AND permissions\_roles.permission\_id = permissions.id  
AND permissions.controller = ‘pages’  
AND permissions.action = ‘login’

so the routing gets completely messed up, taking url/user/login, as the  
name of a book. So by just adding the following:

map.connect ‘user/login’, :controller =\> ‘user’, :action =\> “login”

in the beginning of my routes.rb, I solved my problem.

Hope this is helpful,

Bart

---

<div class="post-metadata">

**Author:** ![Rajesh\_GS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5e9695/32.png) [@Rajesh\_GS](https://www.ruby-forum.com/u/Rajesh_GS)\
**Post date:** [February 16, 2006, 9:22pm UTC](https://www.ruby-forum.com/t/re-userengine-infinite-loop-scott-walter/101893/4 "2006-02-16T21:22:04Z")

</div>

Hello again,

In fact, you will have to do this for all the user related routes, like  
user/show/#, and user/edit\_user/# etc, or it will get confused with the  
other routes you might have. Maybe James could sum a list of all  
possible routes for the UserEngine, and put it as an EXAMPLE\_Routes.rb  
in the distribution. Just like with the WikiEngine, and RikiEngine…

have fun,

Bart

---

<div class="post-metadata">

**Author:** ![Rajesh\_GS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5e9695/32.png) [@Rajesh\_GS](https://www.ruby-forum.com/u/Rajesh_GS)\
**Post date:** [February 16, 2006, 9:34pm UTC](https://www.ruby-forum.com/t/re-userengine-infinite-loop-scott-walter/101893/5 "2006-02-16T21:34:10Z")

</div>

Oops, me again, sorry

Or what you also could write in routes.rb, to cover most (if not all?)  
cases is \

map.connect ‘user/:action/:id’, :controller =\> ‘user’

Won’t bother again 😉

Bart

---

<div class="post-metadata">

**Author:** ![Rajesh\_GS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5e9695/32.png) [@Rajesh\_GS](https://www.ruby-forum.com/u/Rajesh_GS)\
**Post date:** [February 17, 2006, 1:00am UTC](https://www.ruby-forum.com/t/re-userengine-infinite-loop-scott-walter/101893/6 "2006-02-17T01:00:11Z")

</div>

In Bart’s case it was because his routes were grabbing the url  
parameters and not passing them to the appopriate controller, and his  
last post describes an adequate fix. Engine or not, every controller  
would have to be explicitly ‘noted’ in the routes file to avoid being  
interprettetd as a ‘book\_url\_name’ parameter.

So - it’s not really a bug in the engine. It’s the fact that you have  
a set of routes which supercedes the typical :controller/:action/:id  
default in such a complete way that ANY controller needs to be handled  
as a special case. Perhaps the Riki/Wiki engine route documentation  
might be clearer about this, and I’m sure that patches to such  
documentation will be greatly appreciated.

- james

On 2/16/06, Ryan T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> This infinite loop happened to me too. It’s clearly a bug in the  
> engine. If you want to wall off people from /login by default, that’s  
> fine, if strange. But then don’t redirect them there if they don’t  
> have permissions.
> 
> * * *
> 
> engine-users mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org)

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![Rajesh\_GS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5e9695/32.png) [@Rajesh\_GS](https://www.ruby-forum.com/u/Rajesh_GS)\
**Post date:** [February 16, 2006, 11:35pm UTC](https://www.ruby-forum.com/t/re-userengine-infinite-loop-scott-walter/101893/7 "2006-02-16T23:35:07Z")

</div>

This infinite loop happened to me too. It’s clearly a bug in the  
engine. If you want to wall off people from /login by default, that’s  
fine, if strange. But then don’t redirect them there if they don’t  
have permissions.
