Simple Sign in Button

Need a simple sign in button in launch.ly? Here is the code you need.

We used to have rather complex sign in buttons, but I got tired of re-doing the link on each project. So I extracted this logic out in to a much simpler piece of code: the sign_in tag. Here is how I use it …

1{% sign_in class: btn login-popup %}
2  Sign in
3{% endsign_in %}

While you are at it, you might want a fancy pull down menu button for when you are logged in. I normally let the user access their profile, sign out and if they can administer anything, give them access to the launch.ly control panel. See the sample code below on how to do that …

Feel free to customise the menu to your needs. If it’s an commerce site you are running, you might want to bring forward a menu option to access the orders panel.

If you have a question, feel free to ask.

 1{% if signed_in? %}        
 2<div class="btn-group">
 3
 4  <button class="btn btn-small dropdown-toggle" data-toggle="dropdown">
 5    <span id="user-gravatar" class="pull-left">
 6      {{ current_user | gravatar: 15, 'g', 'mm' }}
 7    </span>
 8    {{ current_user.email }} 
 9  </button>
10
11  <ul class="dropdown-menu">
12    {% if current_user.admin? %}
13      <li><a href="{{ '/__/account' | secure_url }}">Site settings</a></li>
14    {% endif %}
15    
16    <li><a href="{{ current_user.profile.url }}">Profile</a></li>
17    <li class="divider"></li>
18    <li><a href="{{ '/__/users/sign_out' | secure_url }}">Sign out</a></li>
19  </ul>
20
21</div>
22{% endif %}

by Craig Sullivan
launch.ly

8 May 2012