# Login Engine - small problem

**URL:** <https://www.ruby-forum.com/t/login-engine-small-problem/102475>\
**Category:** Engines\
**Created:** [February 8, 2006, 7:54pm UTC](https://www.ruby-forum.com/t/login-engine-small-problem/102475 "2006-02-08T19:54:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![da\_pendragon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8491ac/32.png) [@da\_pendragon](https://www.ruby-forum.com/u/da_pendragon)\
**Post date:** [February 8, 2006, 7:54pm UTC](https://www.ruby-forum.com/t/login-engine-small-problem/102475/1 "2006-02-08T19:54:04Z")

</div>

Hi, first of all, thanks for making the login engine, it suits my  
needs perfectly.

I’ve been using the login engine for a web application I’ve developed,  
but I’ve run into a small problem.

Using before\_filter on other controllers works just fine, but I also  
want methods in the UserController that is included in the Login Engine  
to be protected in some cases. For instance, I’d like the signup action  
to be unavailable unless a user is logged in (only valid users can add  
new accounts). I’ve added the normal before\_filter to the  
UserController, but this is obviously not the correct way of doing  
this.

So in short: how can I secure all actions except login in  
UserController?

My thanks in advance for any help you can give

Regards,  
Vegard

---

<div class="post-metadata">

**Author:** ![da\_pendragon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8491ac/32.png) [@da\_pendragon](https://www.ruby-forum.com/u/da_pendragon)\
**Post date:** [February 9, 2006, 10:48am UTC](https://www.ruby-forum.com/t/login-engine-small-problem/102475/2 "2006-02-09T10:48:42Z")

</div>

Easiest solution: Use UserEngine. 😉

2006/2/8, da pendragon [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![da\_pendragon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8491ac/32.png) [@da\_pendragon](https://www.ruby-forum.com/u/da_pendragon)\
**Post date:** [February 9, 2006, 11:06am UTC](https://www.ruby-forum.com/t/login-engine-small-problem/102475/3 "2006-02-09T11:06:43Z")

</div>

You want to override the ‘protect?’ method of the UserController. In  
your /app/controllers folder, create a new user\_controller file,  
something like this:

class UserController \< ApplicationController  
def protect?(action)  
if [‘login’].include?(action)  
return false # only the login action  
is unprotected.  
else  
return true  
end  
end  
end

The Engines plugin will mix this code in with the engine controller  
and use your application method instead. Voila.

- james

On 2/9/06, Ulrik M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> * * *
> 
> 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:** ![da\_pendragon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8491ac/32.png) [@da\_pendragon](https://www.ruby-forum.com/u/da_pendragon)\
**Post date:** [February 9, 2006, 5:09pm UTC](https://www.ruby-forum.com/t/login-engine-small-problem/102475/4 "2006-02-09T17:09:37Z")

</div>

That worked perfectly! Thanks for the quick answers, too!

Regards,  
Vegard
