Display Login Status

I’m using salted login generator and would like my pages to display a
login status bar.

If the user is logged in I want it to show something like:


You are currently logged in as UserX (Logout)

And if they’re not logged in:


Login/Signup

Any ideas?

On Mon, Dec 26, 2005 at 09:21:21AM +0100, Andrew Kendall wrote:


Login/Signup

Any ideas?

after user authenticated store ‘User’ in the session -
on the template it could go like:

<%= link_to_unless( @session[:user].nil?, ‘logout’, {
:controller => ‘foo’, :action => ‘logout’ } %>
<%= link_to_unless( @session[:user], ‘login’, {
:controller => ‘foo’, :action => ‘login’ } %>

or if u prefer more lines:

<% if @session[:user] %>
currently logged in as <%= @session[:user].login %>
<%= link_to ‘logout’, :action => ‘logout’ %>
<% else %>
not logged in <%= link_to ‘login’, :action => ‘login’ %>
<% end %>

but i guess u would have found out yourself…

regards
rene

That doesnt seem to work

MSK wrote:

That doesnt seem to work

Try:

<% if @session[‘user’] %>
currently logged in as <%= @session[‘user’].login %>
<%= link_to ‘logout’, :action => ‘logout’ %>
<% else %>
not logged in <%= link_to ‘login’, :action => ‘login’ %>
<% end %>

Worked for me with salted

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs