Sha256: 5f883f7b6174942cb4b90b2cbee4ee31a67b668e3d0370d687317d4683dd8ec0

Contents?: true

Size: 1.92 KB

Versions: 1

Compression:

Stored size: 1.92 KB

Contents

# CurrentUser

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)

## Getting started

CurrentUser works with Rails 3.2. Add to your Gemfile:

```ruby
gem 'current_user', :git => 'git://github.com/MitinPavel/current_user.git'
```

Install it using bundler:

```console
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. 

Run the generator:

```console
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`:

```ruby
root :to => 'dashboards#show'
```

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

 ```ruby
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:
```console
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.

## License

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
current_user-0.0.1 README.md