Jiff Auth plugin

Plugin details

An alternative (to popular restful_authentication) authentication plugin for Rails

Websitehttp://github.com/snitko/jiff_auth Repositorygit://github.com/snitko/jiff_auth.git Author snitko Tags Auth LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install git://github.com/snitko/jiff_auth.git

USAGE (WITH VIEWS EXAMPLES)
================================

I assume, you will need views at least for:
* login
* new

So, each of these templates goes in 'app/views/users' dir. Let's take a look at 'new' template first. Here's how it might look:

  <% form_for @user, :method => "post", :html => {:multipart => true} do |f| %>
    < input type="text"      name="user[login]" />
    < input type="password"  name="user[password]" />
    < input type="password"  name="user[password_confirmation]" />
    < input type="text"      name="user[email]" />
  <% end %>


If password comes blank, the model will generate password. In any case, the password will be sent to the user(being more accurate, model will invoke UserMailer.deliver_signup(self) ), and it's up to you what are you going to do with it in your UserMailer class. Just note, you must have a UserMailer class with at least to methods: 'signup' and 'lost_password'.

Anyway, if the signup is successful, we're redirected (if you didn't change the defaults!) to the login action. Here's how the view for login might look:

  <% form_for User.new, :url => 'login', :method => "post", :html => {:multipart => true} do |f| %> 
    < input type="text"      name="user[login]" />
    < input type="password"  name="user[password]" />
    
    
    < input value="true" type="checkbox" name="remember_me"/>
  <% end %>


It's simple. But sometimes you might want to give your users an option to login with their 'id', 'email' or 'openid', and you still want to have only one field. Check out the next code:

  <% form_for User.new, :url => 'login', :method => "post", :html => {:multipart => true} do |f| %> 
    
    
    
  <% end %>


The controller will try to guess, what kind of field the user is trying to login with. In fact, you might want to write your own guess rules for that. Just take a look at 'jiff_auth/lib/auth_controller.rb:108' and then redefine 'login_type' method in your controller.

Also make sure, that your 'guess_me_field' is allowed as field for authentication. You can set it in JiffAuth.configure:

  :auth_by => [:login, :email, :id, :openid]


Again, this example shows the defaults, so you don't need this argument, unless you want to add or remove some.

What's also important is that you can only pass a hash of 2 arguments to the model (user[email] and user[password] for example), when authenticating. Otherwise, it will raise error.

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 8 months ago