Hello Liu:
Firstly, I wouldn''t implement an authentication system your self as
there are plenty of good plugins out there for that. Try checking out
* http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated/
* http://svn.techno-weenie.net/projects/plugins/restful_authentication/
Secondly, there are a couple of issues with the code in the
check_authentication method:
session[:intended_action] = action_name # where is action_name
being set/coming from?
redirect_to :action=>"singin_form" Your redirect action is
incorrrect - should be signin_form
Cheers,
Nicholas
On Nov 18, 9:08 am, "刘昊"
<leomayleo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi, folks,
> I''ve run into a weird problem when I was trying to implement
an
> authentication system myself, here is the adminController code,
>
> class AdminController < ApplicationController
> before_filter :check_authentication, :except =>
> [:signin_form, :signin]
>
> def index
> end
>
> def signin_form
> end
>
> def signin
> session[:user] = User.authenticate(params[:username],
> params[:password]).id
> redirect_to :action=>session[:intended_action]
> end
>
> def check_authentication
> unless session[:user]
> session[:intended_action] = action_name
> redirect_to :action=>"singin_form"
> end
> end
> end
>
> I restart my webrick server and I typedhttp://localhost:3000/admin,
> it should go to signin_form.rhtml to ask me sign in, but what happned
> is ever loop sending request to signin_form, any informative tips will
> be appreciated.
>
> All the best,
> Liu Hao
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---