From fbedb1806047513455f0c54c71e841e3c6a1d623 Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Fri, 13 Apr 2012 17:44:39 +0200 Subject: First devise integration. Refs #7 --- Gemfile | 2 + Gemfile.lock | 13 +- app/controllers/application_controller.rb | 2 +- app/models/user.rb | 9 + app/views/layouts/_user_links.erb | 8 + config/application.rb | 5 + config/environments/development.rb | 2 + config/environments/production.rb | 3 + config/initializers/devise.rb | 223 +++++++++++++++++++++++ config/locales/devise.en.yml | 57 ++++++ config/routes.rb | 2 + db/migrate/20120413142837_devise_create_users.rb | 49 +++++ db/schema.rb | 76 ++------ spec/models/user_spec.rb | 5 + 14 files changed, 397 insertions(+), 59 deletions(-) create mode 100644 app/models/user.rb create mode 100644 config/initializers/devise.rb create mode 100644 config/locales/devise.en.yml create mode 100644 db/migrate/20120413142837_devise_create_users.rb create mode 100644 spec/models/user_spec.rb diff --git a/Gemfile b/Gemfile index 3ef133015..9ca6122ed 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,8 @@ gem 'user_interface', :git => 'git://sim.dryade.priv/user_interface' gem 'apartment', :git => 'git://github.com/dryade/apartment.git' +gem 'devise' + gem "map_layers", "~> 0.0.4" platforms :jruby do diff --git a/Gemfile.lock b/Gemfile.lock index 11db7ca96..340a990ad 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://sim.dryade.priv/user_interface - revision: 0d22ebf5bb92d2c0ce27f1e395f6b3c82ce17628 + revision: a9f62359e65e42e9329bf4dbbd0c5a63a42119a4 specs: user_interface (0.0.1) rails (~> 3.1.0) @@ -97,6 +97,8 @@ GEM autotest-rails (4.1.1) ZenTest (= 4.5) autotest-standalone (4.5.9) + bcrypt-ruby (3.0.1) + bcrypt-ruby (3.0.1-java) bouncy-castle-java (1.5.0146.1) builder (3.0.0) capistrano (2.9.0) @@ -136,6 +138,11 @@ GEM cucumber (>= 1.1.3) nokogiri (>= 1.5.0) database_cleaner (0.7.1) + devise (2.0.4) + bcrypt-ruby (~> 3.0) + orm_adapter (~> 0.0.3) + railties (~> 3.1) + warden (~> 1.1.1) diff-lcs (1.1.3) erubis (2.7.0) execjs (1.2.13) @@ -201,6 +208,7 @@ GEM net-ssh (>= 1.99.1) nokogiri (1.5.0) nokogiri (1.5.0-java) + orm_adapter (0.0.7) pg (0.11.0) polyamorous (0.5.0) activerecord (~> 3.0) @@ -300,6 +308,8 @@ GEM jruby-rack (>= 1.0.0) rake (>= 0.8.7) rubyzip (>= 0.9.4) + warden (1.1.1) + rack (>= 1.0) will_paginate (3.0.3) xpath (0.1.4) nokogiri (~> 1.3) @@ -325,6 +335,7 @@ DEPENDENCIES cucumber cucumber-rails database_cleaner + devise factory_girl factory_girl_rails formtastic diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7050568de..ae953a25a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,4 +1,4 @@ class ApplicationController < ActionController::Base protect_from_forgery - + before_filter :authenticate_user! end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 000000000..b2f7c8ec9 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,9 @@ +class User < ActiveRecord::Base + # Include default devise modules. Others available are: + # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable + devise :database_authenticatable, :registerable, + :recoverable, :rememberable, :trackable, :validatable + + # Setup accessible (or protected) attributes for your model + attr_accessible :email, :password, :password_confirmation, :remember_me +end diff --git a/app/views/layouts/_user_links.erb b/app/views/layouts/_user_links.erb index 41d01375c..f82d4d7b4 100644 --- a/app/views/layouts/_user_links.erb +++ b/app/views/layouts/_user_links.erb @@ -1,5 +1,13 @@