andrew-KR6O7HwU5NFCpjqP0VxSwUEOCMrvLtNR@public.gmane.org
2006-Oct-06 19:42 UTC
Newby needs advice on membership function
I am developing a support ticket system in Ruby and need to know if there are any modules or anything that can be added to a project to require a user to log in to the system first and then be allowed access to the support ticket system. If not, how would I go about verifying if a user is logged in before being allowed to view the pages in the site? I appreciate the advice! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
there are several generators and plugins for authentication, although i have not used any of them. in your controller though, you should add something like before_filter :check_authentication with a protected check_authentication method in your controller. in that, you can check to see if a use is logged in, if not, you can redirect to your login page to prompt the user. hope that helps some. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
andrew-KR6O7HwU5NFCpjqP0VxSwUEOCMrvLtNR@public.gmane.org wrote:> I am developing a support ticket system in Ruby and need to know if > there are any modules or anything that can be added to a project to > require a user to log in to the system first and then be allowed access > to the support ticket system. > > If not, how would I go about verifying if a user is logged in before > being allowed to view the pages in the site? > > I appreciate the advice!Use a before_filter to handle things like this. Filter can run before all actions in the application, and if a filter renders, redirects, or returns "false", then the action that is being called is never executed. Here is a simple before_filter setup that will deny anyone access to all action in a controller. http://pastie.caboo.se/16469 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
andrew-KR6O7HwU5NFCpjqP0VxSwUEOCMrvLtNR@public.gmane.org
2006-Oct-20 23:38 UTC
Re: Newby needs advice on membership function
Alex, Thanks for the simple explanation. That helped a lot. However, I have another question. You are setting the session[:user_id] in your ApplicationController. How do I make that persistent throughout my application? It does not appear to be setting the session variable as a "global" option in the ApplicationController. When I click a link to another :controller in the same application the other controller can''t retrieve that session information. Is there a trick I am missing? Thanks again for your help. Andrew --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---