# Overriding login route?

**URL:** <https://www.ruby-forum.com/t/overriding-login-route/125841>\
**Category:** Radiant CMS\
**Created:** [January 12, 2008, 6:53pm UTC](https://www.ruby-forum.com/t/overriding-login-route/125841 "2008-01-12T18:53:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 12, 2008, 6:53pm UTC](https://www.ruby-forum.com/t/overriding-login-route/125841/1 "2008-01-12T18:53:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 12, 2008, 6:58pm UTC](https://www.ruby-forum.com/t/overriding-login-route/125841/2 "2008-01-12T18:58:43Z")

</div>

The obvious approach didn’t work…

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

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 12, 2008, 7:04pm UTC](https://www.ruby-forum.com/t/overriding-login-route/125841/3 "2008-01-12T19:04:56Z")

</div>

On 1/12/08, Mario T. Lanza [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 12, 2008, 8:16pm UTC](https://www.ruby-forum.com/t/overriding-login-route/125841/4 "2008-01-12T20:16:17Z")

</div>

> 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.
