Re: User Login

Robert Walker
Fri, 06 Jun 2008 02:53:10 -0000

I agree with Ryan here. Start off with a decent plugin for
authentication. That will do 2 things for you: 1. It''s likely
they''ll
do a job better you would yourself, and 2. You can learn a lot by
reading through the code in these plugins.

What I also like about these plugins is that you''re not stuck with a
"gate-keeper" style login scenario. Instead you are provided fine
grained control of how you manage accesses to your controller actions.
They make it easy to provide some controller actions for public access
and some restricted access. They are very flexible in this regard and
well worth a few minutes of your time getting familiar with them.

With restful_authentication, for example, you could do this:

<% if logged_in? %>
  Login Form...
<% else %>
 Welcome your user...
<% end %>

Makes the intent very clear, so if anyone else were to inspect your
code they would understand it''s function right away.

On Jun 5, 9:14 pm, "Ryan Bigg (Radar)"
<radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> The login generator was deprecated ages ago, you could try using
> acts_as_authenticated or restful_authentication (the latter being the
> latest), and seeing if they work (they should)
>
>
>
> On Fri, Jun 6, 2008 at 10:02 AM, cz231
<cz2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > That still doesn''t work. Maybe I haven''t given you
enough info...I''m
> > using the LoginGenerator if that changes things...
> >http://wiki.rubyonrails.org/rails/pages/LoginGenerator
> > Thanks.
> > On Jun 4, 11:47 pm, Fredrik Thuresson
<fredrik.thures...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > wrote:
> > > <% if session[:uid].blank? %>
> > >     Login Form
> > > <% else %>
> > >     <%="Hello id: #{session[:uid]}" %>
> > > <% end %>
>
> > > -Fredrik
>
> > > cz231 wrote:
> > > > Hmm...that doesn''t work...Does anyone else know?
> > > > I''ll have to look into that plugin too...
>
> > > > Right now I''m trying
> > > > <% if session[:uid] != nil  -%>
> > > > Welcome User
>
> > > >                    <% else -%>
> > > >            Login Form
> > > > <% end -%>
>
> > > > Thanks for any help...
>
> > > > On Jun 2, 9:02 pm, Cayce Balara
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
> > > > wrote:
>
> > > >> cz231 wrote:
>
> > > >>> Oops, sorry about that, I accidentally sent it
somehow...
>
> > > >>> Anyway, for the <% if session[:uid] = @user.id
-%> , I don''t know
> > what
> > > >>> would go in there...
>
> > > >>> Thanks for your help...
>
> > > >> Really all you want to know is if there is a
session[:uid] -
>
> > > >> <% if session[:uid] %>
>
> > > >> if there is then the user is logged in, otherwise it
will be nil.
>
> > > >> However, there''s some more to it. I would
recommend you pull down the
> > > >> restful_authentication plugin, run the generator and
then examine the
> > > >> code to see how they do all this, which will teach you a
lot.
>
> > > >> For instance, Restful_Authentication exposes the
currently logged in
> > > >> user with "current_user" and also methods like
"logged_in?" and
> > > >> "authorized?" that will assist with what you
are trying to do.
> > > >> --
> > > >> Posted viahttp://www.ruby-forum.com/.
>
> --
> Appreciated my help?
> Recommend me on Working With
Railshttp://workingwithrails.com/person/11030-ryan-bigg
--~--~---------~--~----~------------~-------~--~----~
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