Overriding login route?

I want to substitute my own login screen to the user so that upon a
failed page access the user doesn’t get redirected to the admin/login
screen. I don’t want the user to see the radiant backend. To do so,
and it works, I overrode the LoginSystem in the following fashion:

module LoginSystem
protected

def authenticate
  action = params['action'].to_s.intern
  if no_login_required? or (current_user and

user_has_access_to_action?(action))
true
else
if current_user
permissions =
self.class.controller_permissions[self.class][action]
flash[:error] = permissions[:denied_message] || ‘Access
denied.’
redirect_to permissions[:denied_url] || { :action => :index }
else
redirect_to user_login_url #changed from login_url
end
false
end
end
end

I hate to copy and override a complete method when only one line change
is necessary. I simply want the login_url to redirect to ‘user/login’
rather than ‘admin/login’. I tried overriding the routes in several
ways without any luck. Is this a rather simple change someone might
know off the top of their head?

Thanks.

The obvious approach didn’t work…

define_routes do |map|
map.login ‘user/login’, :controller => ‘user’, :action => ‘login’
end

On 1/12/08, Mario T. Lanza [email protected] wrote:

define_routes do |map|
map.login ‘user/login’, :controller => ‘user’, :action => ‘login’
end

What about defining your own user_login_url method on LoginSystem?


John L.
http://wiseheartdesign.com

What about defining your own user_login_url method on LoginSystem?

That’s exactly what I did. See the top of the thread. What I’m trying
to avoid is substituting an entire method override for “authenticate” in
my extension. I didn’t actually modify the LoginSystem file that comes
with radiant, just overrode the method from my extension.
Unfortunately, this approach requires me to copy the entire block of
code (as it appears in your original file) and make a minor
modification. If you ever change it, then I don’t get your changes
because of my complete override. My goal was to leave your code as
intact as possible and override the least amount at just the precise
location. The only way I see to do that is to reroute the login_url
from your backend ‘admin/login’ to my frontend ‘user/login’. I already
have a user_login_url, but I need your LoginSystem to acknowledge it.

Thanks for giving this a bit of thought.