Forum: Rails Engines Login Engine - small problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
844f025af4e8d6db36d94335034b73ac?d=identicon&s=25 da pendragon (Guest)
on 2006-02-08 19:54
(Received via mailing list)
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
A0a0bf451db6d1e06be88b4ce3cd72a1?d=identicon&s=25 Ulrik Mikaelsson (Guest)
on 2006-02-09 10:48
(Received via mailing list)
Easiest solution: Use UserEngine. ;)

2006/2/8, da pendragon <dapendragon@gmail.com>:
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 James Adam (Guest)
on 2006-02-09 11:06
(Received via mailing list)
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 Mikaelsson <ulrik.mikaelsson@gmail.com> wrote:
> >
> >
> >
> >
> >
> _______________________________________________
> engine-users mailing list
> engine-users@lists.rails-engines.org
> http://lists.rails-engines.org/listinfo.cgi/engine...
>


--
* J *
  ~
844f025af4e8d6db36d94335034b73ac?d=identicon&s=25 da pendragon (Guest)
on 2006-02-09 17:09
(Received via mailing list)
That worked perfectly! Thanks for the quick answers, too!

Regards,
Vegard
This topic is locked and can not be replied to.