ECM User Area
Installation
Add it to your Gemfile:
# Gemfile
gem 'ecm_user_area2'
Install:
rails g ecm:user_area:install
Add Migrations and migrate:
rake ecm_user_area:install:migrations && rake db:migrate
Optionally, create a default user ([email protected]/password):
rake ecm:user_area:create_default_user
Add routes:
# config/routes.rb
mount Ecm::UserArea::Engine, at: '/auth'
Add current_user helpers to your application controller:
# app/controllers/application_controller.rb
include Controller::RedirectBackConcern
include Controller::CurrentUserConcern
Usage
to secure a controller, add following before_action:
# app/controllers/my_secure_controller.rb
before_action :authenticate_user!
When you visit any controller actions, you will be redirected to the sign in form.
Adding helper methods
# app/controllers/application_controller.rb
include Controller::CurrentUserConcern
This gives you #current_user_session, #current_user, user_signed_in?
Using the navigation helper
# app/controllers/application_controller.rb
helper Ecm::UserAreaHelper
Running Specs
gem install bundler
bundle
cd spec/dummy && rake db:migrate RAILS_ENV=test && cd ../..
guard
This project rocks and uses MIT-LICENSE.