No commit activity in last 3 years
No release in over 3 years
An authentication gem for the pre-production (mainly) phase of the application lifecycle. Provide a simple sign in page with a list of all users in the application. Click on any user logins you to the application under the user.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

< 5, >= 3.2
 Project Readme

CurrentUser

Build Status Code Climate

Dev phase auth for Rails.

What it is

  • A simple authentication gem for the development (pre-production) phase
  • Familiar rails conventions: #current_user, #signed_in?
  • A minimalistic signin page with a list of all available users (just click on a user and you will be logged in under the user)
  • An opportunity to replace it with one of the mature solution (assuming Devise)

What it is not

  • An authentication solution for the production phase of the application lifecycle
  • An authorization gem (although in the future it might get some authorization features to mimic Devise)

How it looks like

[Screenshot of the sign in page]

Getting started

CurrentUser works with Rails 3.2 and 4.0 using Ruby 1.9.3 or Ruby 2.0.

Add to your Gemfile:

gem "current_user"

Install it using bundler:

bundle install

Note: CurrentUser assumes your application already has a few users. So if the assumption is false, create User active record class AND/OR add several users to the database. It also assumes User has "email" attribute/method. If it is not the case, add "email" or change configuration in config/initializers/current_user.rb.

Run the generator:

rails generate current_user:install

The generator:

  • creates a file with a unique authentication key for your application
  • creates an initializer
  • inject routing to your application
  • show README

Specify root in config/routes.rb:

root :to => 'dashboards#show'

Add before filter to app/controllers/application_controller.rb:

before_filter :authenticate_user!

Try to visit one of protected pages of your application (for example root). You will see "Unauthorized" error page.

Run a rake task what shows a path to your sign in page:

rake current_user:sign_in_path

Visit your sign in page. You will see a list of users of your application. Click on a user and the link will take you to the root page of the application.

Congratulations. Your application has a simple authentication solution. Send a link to the sign in page to your customer and she/he will love to test your app manually :)

Helpers

CurrentUser creates some helpers to use inside your controllers and views.

To verify if a user is signed in, use the following helper:

signed_in?

For the current signed-in user, this helper is available:

current_user

Logo

CurrentUser on RubyGems

License

It uses MIT license. See MIT-LICENSE file in the root directory.