RubyGems Navigation menu

easy_rails_authentication 0.0.3

EasyRailsAuthentication

This project uses MIT-LICENSE. It's a standard rails plugin, so you can include it from your application's Gemfile or your plugin's gemspec.

Setup

The first thing you'll want to do is migrate your datebase to create its tables, using `rake easy_rails_authentication_engine:install:migrations`.

Then, in your ApplicationController, add these lines:

protected
  include EasyRailsAuthentication::AuthenticationHelper
  before_filter :require_authentication
  before_filter :require_administrator_priveleges

This will guarantee that all your pages can only be accessed by an administrator, but you can, of course, override that in individual controllers using `skip_before_filter …`. See examples in test/dummy/app/controllers/dummy_routes_controller.rb.

A few other basic setup requirements:

  1. Assets: Your application's javascripts and stylesheets manifests should include the plugin's appropriate index files using `//= require easy_rails_authentication` (for javascripts) and `*= require easy_rails_authentication` (for stylesheets).

  2. Configure the application's `config.action_mailer.default_url_options` since the plugin sends e-mails. Do this in config/environments/*.rb or in config/application.rb. Assuming you've set MyHost and MyPort to the appropriate values for your domain, configure as follows:

    config.action_mailer.default_url_options = { :host => "#{MyHost}:#{MyPort}" }
    
  3. Configure some EasyRailsAuthentication configuration parameters, as follows:

    EasyRailsAuthentication.configure do |config|
      config.contact_info = "..." # The way users should contact you with questions about their accounts.  Phone number, email, or both.
      config.send_mail_from = "..." # The email address that this application sends email from
      config.signature = "..." # The last line of all emails.  The name you go by, or "Cheers!" or whatever else you'd like
    end
    
  4. config/routes.rb must define a root route.

Partial templates

You can include partial templates for logging in an updating user information. In your view or layout:

<%= render "users/show" if logged_in? %>
<%= render "sessions/login" %>

The `sessions/login` template will automatically detect when a user is logged in and replace the login form with a logout button. The `users/show` template isn't as graceful, so `if logged_in?` is recommended.

Pages

Running `rake routes` will give you the full picture, but practically speaking, the following paths are the ones you may want to link to:

users_path (index of all users–only admins can view this) edit_user_path (requires an ID to be passed as an arg) new_user_path login_path forgot_password_path (for the user to request an e-mail with a link to reset his password)

API

`app/helpers/easy_rails_authentication/authentication_helper.rb` defines several functions useful for authentication. The ones you'll primarily need (in addition to the filters mentioned above) are:

logged_in? logged_in_as?(user) log_in_as(user) log_out

Because these are helper functions, they are accessible from all views and helpers. They should also be accessible from all controllers if you've included the helper in your ApplicationController as described above.

There are also plenty of useful functions in other helper files, so take a look and you may find some code you want to re-use.

Contributing

The usual github for process. Contant info is in the gemspec file.

Versions:

  1. 0.0.8 - December 6, 2012 (736 KB)
  2. 0.0.7 - October 30, 2012 (627 KB)
  3. 0.0.6 - October 30, 2012 (99 KB)
  4. 0.0.4 - October 11, 2012 (552 KB)
  5. 0.0.3 - October 10, 2012 (308 KB)
Show all versions (8 total)

Development Dependencies:

Authors:

  • Isaac Betesh

Owners:

B8dc4b76792ff3c8cd993aa4c9c467f6

Total downloads 6,343

For this version 866

Show all versions (8 total)

Required Ruby Version: None

Licenses:

N/A

Gemfile:
gem 'easy_rails_authentication', '~> 0.0.3' = Copy to clipboard Copied!

install:
gem install easy_rails_authentication -v 0.0.3 = Copy to clipboard Copied!

Links: