I had the same requirement in an app I developed. I'm not exactly an
expert, but the way I did it was to overwrite the method
_set_return_to by putting the following in app/controllers/
application.rb -

-------------------
class Exceptions < Merb::Controller
  private
  # Overwriting the definition in merb-auth-more/mixins/
redirect_back.rb
  def _set_return_to
    session[:return_to] ||= []
    unless request.uri =~ /login/
      # i.e. we will go to where we were going to before the exception
      session[:return_to] << request.uri
    else
      # i.e. if we got here from the login link, we will go back to
where we came from
      session[:return_to] << request.referer
    end
    session[:return_to]
  end
end
------------------

Mark.



Chris Hoeppner wrote:
> Tony,
>
> Thank you for the reply.
>
> This, unfortunately, is not how my app works, although certain parts of
> the app may be adapted. Mainly, an unauthenticated user may view most
> paths, which doesn't mean he can view all the content. For example, we
> have news entries that show only for authenticated users, but also
> public news entries. The forum slice I'm writing works about the same
> principle: unauthenticated may view public forums, but not post;
> authenticated users may post in public; users with role "officer" can
> view and post in the officer forum, etc.
>
> I've not had a close enough look at the auth slice's internals, but I'm
> hoping there could be an easy way to have /login always redirect to the
> referring url?
>
> ~Chris
>
> Tony Mann escribió:
> > Chris,
> >
> > Normally you would use "before :ensure_authenticated" in your
> > controller. When an action in the controller is called, if the user is
> > not logged in this forces the login screen to show up before the
> > action is performed.
> >
> > ..tony..
> >
> > On Mon, Oct 12, 2009 at 5:32 AM, Chris <[email protected]
> > <mailto:[email protected]>> wrote:
> >
> >     Hello,
> >
> >     Is there any quick (as in: no need to override code) way to have
> >     the login action from merb-auth-slice-password redirect to
> >     wherever the user was before (aka: referrer to /login)?
> >
> >
> >
> >
> > >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to