Displaying 13 results from an estimated 13 matches for "intended_action".
2006 Aug 07
2
Ugggh..another recipes question
...Routing Error
No url can be generated for the hash {}
I''m guessing it''s coming from the redirect-
def login
if request.post?
session[:user] = User.authenticate(params[:first_name],
params[:last_name],
params[:password]).id
redirect_to :action => session[:intended_action],
:controller => session[:intended_controller]
I don''t see an explanation in the recipe about this redirect. Do I need it ?
TIA
Stuart
2006 Aug 12
7
Redirect back to last page?
I have a few pages where a user may do something (add tags, login, etc)
and I would like to redirect them back to the last page they were at
before calling that action. Is there an easy way to do this?
--
Posted via http://www.ruby-forum.com/.
2006 Aug 13
3
Render nothing; go nowhere
...ecial) and go to no specific URL. Any ideas? This is what my
login/login action looks like.
def login
session[:user_id] = nil
if request.post?
user = User.authenticate(params[:name], params[:password])
if user
session[:user_id] = user.id
if session[:intended_action].nil? ||
session[:intended_controller].nil?
if (@request.env[''HTTP_USER_AGENT''] == "MyCustomCClient")
#did it come from my C++ program?
#### <---- I need something here -----> ####
else
redirect_to(:action =&...
2006 Aug 07
8
Login form question
I''m using Rails Recipes to create a login form but instead of username
and password, my setup is firstname, lastname, password.
I seemed to be gramatically challenged and not sure how to set up the
parameter list. Can anyone offer up a suggestion.
The book shows the method starting like:
if request.post?
user = User.find(:first, :conditions => [''username = ?'' ,
2006 Aug 07
8
Rails Recipes question - authenticating users
Didn''t think I''d be back so quick with another question but here goes:
In this recipe for the signin or login (as I call it) there are these
two lines if the user authenticates correctly:
session[:user] = user.id
redirect_to :action => session[:intended_action],
:controller => session[:intended_controller]
So I''m not seeing anything in the way of an explanation but reading
the code it looks like there should be a session controller with a
session action . Is that correct ?
Right now I have a sessions table set up, I''ve made the cha...
2006 Jul 07
13
Rails Recipes Book: Authentication
Hi,
The user/login management system in Chapter 31: Authenticating Your
Users and Chapter 32: Authorizing Users with Roles of Chad Fowler''s
Rails Recipes looks reasonable and adequate. However, when I ran the
Chapter 31 code, I get the following error:
Username or password invalid
And I am not even given the chance to sign in; that is, the signin form
does not appear at all.
Has
2006 Apr 21
1
Catch authentication result from a model in a controller
...ser
end
end
#controller---------------------------------------------
class AdminController < ApplicationController
before_filter :check_authentication, :except => [:signin_form, :signin]
def index
render "admin"
end
def check_authentication
unless session[:user]
session[:intended_action] = action_name
redirect_to :action => "signin_form"
end
end
def signin_form
render "login_form"
end
def signin
session[:user] = User.authenticate(params[:username],
params[:password]).id
redirect_to :action => session[:signin_form]
end
def signout
session[:...
2006 Jun 30
8
before_filter: nil vs. true vs. false
...ue if
everything is ok and false if not. How does the filter below work
then (from the Rails Recipies book)?
It would return nil if there''s a user in the session. Does nil count
as true?
before_filter :check_authentication
def check_authentication
unless session[:user]
session[:intended_action] = action_name
session[:intended_controller] = controller_name
redirect_to :action => "signin"
end
end
Thanks, Joel
--
http://wagerlabs.com/
2006 Jul 09
1
Accessing the name of a controller''s module?
...;You must log in to continue."
redirect_to :controller => "/account", :action => "log_in"
end
Then once the action I''m redirected to is completed I use this code to
return the user to the appropriate original page:
redirect_to :action => session[:intended_action],
:controller => session[:intended_controller]
Do I need a line that works like:
session[:intended_module] = module_name
Or am I totally barking up the wrong tree and should not be
redirecting in and out of modules? It seems repititious to have
different log in methods for...
2006 May 19
0
No luck with multiple before_filters
I''ve got these two lines set up in my controller
before_filter :check_authentication
before_filter :check_max_hands, :only => [ :play ]
Here''s the corresponding code for each
def check_authentication
unless session[:user] and authorize?(session[:user])
session[:intended_action] = request.request_uri
redirect_to :controller => ''user'', :action => ''signin''
return false
end
end
def check_max_hands
u = current_user
if !u.account_type.unlimited? && u.hands_played_this_month >=
u.account_type.hand...
2006 Aug 01
0
How to retrieve :web when redirecting to an Instiki page?
...em with the redirection in my signin method, which looks like
this:
def signin
ession[:user] = User.authenticate(params[:username],
params[:password]).id
redirect_to :web=> session[:intended_web],
:controller => session[:intended_controller],
:action => session[:intended_action],
:id => session[:intended_id]
end
I realize that session[:intended_web] is a naive attempt and returns nil
since that session variable doesn''t exist, so how should I go about
retrieving the intended web''s name upon signin redirection?
(Of course if there is a...
2006 Mar 13
7
Problem with params
...@user = User.new
else
@user = User.new(params[:user])
# TODO: wrap this in a rescue block to handle exception
authenticated_user = @user.try_to_authenticate
if authenticated_user
session[:user_id] = authenticated_user.id
redirect_to :action => session[:intended_action], :controller =>
session[:intended_controller]
else
flash[:notice] = ''Invalid username or password.''
end
end
end
I get an error on the User.find(..) line that there is no such thing as
params[]. I had it working but then I edited/moved the code aro...
2006 Jul 02
3
2 before_filters, only want one to render something
...s
allowed. Is there a way that I can make authorize skip
admin_authorize? Or will I have to go through and pick only one method
to be before_filtered for each action?
def authorize #inspired by rails recipes
unless session[:user]
flash[:notice] = "Please log in"
session[:intended_action] = action_name
session[:intended_controller] = controller_name
session[:intended_id] = params[:id] || nil
redirect_to(:controller => "account", :action => "login")
return
end
end
def admin_authorize
unless session[:user] && User.find(session[:u...