Redirecting after a login

64 views
Skip to first unread message

kez

unread,
Sep 14, 2009, 9:05:38 AM9/14/09
to Ramaze
Hullo -

In earlier versions of Ramaze, there was some example code to redirect
the user after a successful login to the page they requested (I
believe this used the stack helper?)

Could anyone dig out this snippet, or if there is a better technique,
provide that? I am using a login "framework" as per
http://www.justkez.com/user-authentication-with-ramaze.

Cheers,

kez.

Pistos

unread,
Sep 14, 2009, 9:20:51 AM9/14/09
to Ramaze

Gavin Kistner

unread,
Sep 14, 2009, 9:33:17 AM9/14/09
to ram...@googlegroups.com
On Sep 14, 2009, at 7:05 AM, kez wrote:
> In earlier versions of Ramaze, there was some example code to redirect
> the user after a successful login to the page they requested (I
> believe this used the stack helper?)
>
> Could anyone dig out this snippet

# extracted from pre-Innate app:
class MainController < Ramaze::Controller
helper :aspect
helper :stack

before_all {
@action = Ramaze::Action.current.name.to_sym
login_required unless @action == :login
}

def login_required
unless logged_in?
call( :login )
end
end

def logged_in?
session[ :active_user_id ]
end

def login
email, password = request[ :email ], request[ :password ]
if email && password
email = email.downcase
user = User.find :email=>email, :active=>true
session[ :active_user_id ] = user.pk

answer if inside_stack?
redirect '/'
end

@title = "Login"
if email || password
@failed_login = true
end
end

end

kez

unread,
Sep 14, 2009, 12:36:41 PM9/14/09
to Ramaze
Both -

Thanks for your responses, I got it working by pushing request.path
into the stack, couldn't get request.referer to load in properly.

kez.
Reply all
Reply to author
Forward
0 new messages