loyal_devise 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/.travis.yml +15 -0
- data/CHANGELOG.rdoc +881 -0
- data/CONTRIBUTING.md +12 -0
- data/Gemfile +31 -0
- data/Gemfile.lock +154 -0
- data/MIT-LICENSE +20 -0
- data/README.md +388 -0
- data/Rakefile +34 -0
- data/app/controllers/devise/confirmations_controller.rb +44 -0
- data/app/controllers/devise/omniauth_callbacks_controller.rb +31 -0
- data/app/controllers/devise/passwords_controller.rb +57 -0
- data/app/controllers/devise/registrations_controller.rb +120 -0
- data/app/controllers/devise/sessions_controller.rb +51 -0
- data/app/controllers/devise/unlocks_controller.rb +45 -0
- data/app/controllers/devise_controller.rb +193 -0
- data/app/helpers/devise_helper.rb +26 -0
- data/app/mailers/devise/mailer.rb +16 -0
- data/app/views/devise/_links.erb +3 -0
- data/app/views/devise/confirmations/new.html.erb +12 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise/passwords/edit.html.erb +16 -0
- data/app/views/devise/passwords/new.html.erb +12 -0
- data/app/views/devise/registrations/edit.html.erb +25 -0
- data/app/views/devise/registrations/new.html.erb +18 -0
- data/app/views/devise/sessions/new.html.erb +17 -0
- data/app/views/devise/shared/_links.erb +25 -0
- data/app/views/devise/unlocks/new.html.erb +12 -0
- data/config/locales/en.yml +59 -0
- data/devise.gemspec +26 -0
- data/gemfiles/Gemfile.rails-3.1.x +35 -0
- data/gemfiles/Gemfile.rails-3.1.x.lock +167 -0
- data/lib/devise/controllers/helpers.rb +273 -0
- data/lib/devise/controllers/rememberable.rb +53 -0
- data/lib/devise/controllers/scoped_views.rb +18 -0
- data/lib/devise/controllers/url_helpers.rb +68 -0
- data/lib/devise/delegator.rb +17 -0
- data/lib/devise/failure_app.rb +188 -0
- data/lib/devise/hooks/activatable.rb +12 -0
- data/lib/devise/hooks/forgetable.rb +10 -0
- data/lib/devise/hooks/lockable.rb +8 -0
- data/lib/devise/hooks/rememberable.rb +7 -0
- data/lib/devise/hooks/timeoutable.rb +26 -0
- data/lib/devise/hooks/trackable.rb +10 -0
- data/lib/devise/mailers/helpers.rb +92 -0
- data/lib/devise/mapping.rb +173 -0
- data/lib/devise/models/authenticatable.rb +269 -0
- data/lib/devise/models/confirmable.rb +271 -0
- data/lib/devise/models/database_authenticatable.rb +127 -0
- data/lib/devise/models/lockable.rb +194 -0
- data/lib/devise/models/omniauthable.rb +28 -0
- data/lib/devise/models/recoverable.rb +141 -0
- data/lib/devise/models/registerable.rb +26 -0
- data/lib/devise/models/rememberable.rb +126 -0
- data/lib/devise/models/timeoutable.rb +50 -0
- data/lib/devise/models/token_authenticatable.rb +90 -0
- data/lib/devise/models/trackable.rb +36 -0
- data/lib/devise/models/validatable.rb +67 -0
- data/lib/devise/models.rb +129 -0
- data/lib/devise/modules.rb +30 -0
- data/lib/devise/omniauth/config.rb +46 -0
- data/lib/devise/omniauth/url_helpers.rb +19 -0
- data/lib/devise/omniauth.rb +29 -0
- data/lib/devise/orm/active_record.rb +4 -0
- data/lib/devise/orm/mongoid.rb +4 -0
- data/lib/devise/param_filter.rb +42 -0
- data/lib/devise/rails/routes.rb +447 -0
- data/lib/devise/rails/warden_compat.rb +44 -0
- data/lib/devise/rails.rb +55 -0
- data/lib/devise/strategies/authenticatable.rb +177 -0
- data/lib/devise/strategies/base.rb +21 -0
- data/lib/devise/strategies/database_authenticatable.rb +21 -0
- data/lib/devise/strategies/rememberable.rb +56 -0
- data/lib/devise/strategies/token_authenticatable.rb +57 -0
- data/lib/devise/test_helpers.rb +132 -0
- data/lib/devise/time_inflector.rb +15 -0
- data/lib/devise/version.rb +4 -0
- data/lib/devise.rb +445 -0
- data/lib/generators/active_record/devise_generator.rb +80 -0
- data/lib/generators/active_record/templates/migration.rb +20 -0
- data/lib/generators/active_record/templates/migration_existing.rb +27 -0
- data/lib/generators/devise/devise_generator.rb +25 -0
- data/lib/generators/devise/install_generator.rb +25 -0
- data/lib/generators/devise/orm_helpers.rb +33 -0
- data/lib/generators/devise/views_generator.rb +117 -0
- data/lib/generators/mongoid/devise_generator.rb +58 -0
- data/lib/generators/templates/README +35 -0
- data/lib/generators/templates/devise.rb +241 -0
- data/lib/generators/templates/markerb/confirmation_instructions.markerb +5 -0
- data/lib/generators/templates/markerb/reset_password_instructions.markerb +8 -0
- data/lib/generators/templates/markerb/unlock_instructions.markerb +7 -0
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +15 -0
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +19 -0
- data/lib/generators/templates/simple_form_for/passwords/new.html.erb +15 -0
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +22 -0
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +17 -0
- data/lib/generators/templates/simple_form_for/sessions/new.html.erb +15 -0
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +15 -0
- data/test/controllers/custom_strategy_test.rb +63 -0
- data/test/controllers/helpers_test.rb +254 -0
- data/test/controllers/internal_helpers_test.rb +111 -0
- data/test/controllers/sessions_controller_test.rb +58 -0
- data/test/controllers/url_helpers_test.rb +60 -0
- data/test/delegator_test.rb +20 -0
- data/test/devise_test.rb +73 -0
- data/test/failure_app_test.rb +222 -0
- data/test/generators/active_record_generator_test.rb +76 -0
- data/test/generators/devise_generator_test.rb +40 -0
- data/test/generators/install_generator_test.rb +14 -0
- data/test/generators/mongoid_generator_test.rb +24 -0
- data/test/generators/views_generator_test.rb +53 -0
- data/test/helpers/devise_helper_test.rb +52 -0
- data/test/indifferent_hash.rb +34 -0
- data/test/integration/authenticatable_test.rb +634 -0
- data/test/integration/confirmable_test.rb +299 -0
- data/test/integration/database_authenticatable_test.rb +83 -0
- data/test/integration/http_authenticatable_test.rb +98 -0
- data/test/integration/lockable_test.rb +243 -0
- data/test/integration/omniauthable_test.rb +134 -0
- data/test/integration/recoverable_test.rb +307 -0
- data/test/integration/registerable_test.rb +346 -0
- data/test/integration/rememberable_test.rb +159 -0
- data/test/integration/timeoutable_test.rb +141 -0
- data/test/integration/token_authenticatable_test.rb +162 -0
- data/test/integration/trackable_test.rb +93 -0
- data/test/mailers/confirmation_instructions_test.rb +103 -0
- data/test/mailers/reset_password_instructions_test.rb +84 -0
- data/test/mailers/unlock_instructions_test.rb +78 -0
- data/test/mapping_test.rb +128 -0
- data/test/models/authenticatable_test.rb +8 -0
- data/test/models/confirmable_test.rb +392 -0
- data/test/models/database_authenticatable_test.rb +190 -0
- data/test/models/lockable_test.rb +274 -0
- data/test/models/omniauthable_test.rb +8 -0
- data/test/models/recoverable_test.rb +206 -0
- data/test/models/registerable_test.rb +8 -0
- data/test/models/rememberable_test.rb +175 -0
- data/test/models/serializable_test.rb +49 -0
- data/test/models/timeoutable_test.rb +47 -0
- data/test/models/token_authenticatable_test.rb +56 -0
- data/test/models/trackable_test.rb +14 -0
- data/test/models/validatable_test.rb +117 -0
- data/test/models_test.rb +180 -0
- data/test/omniauth/config_test.rb +58 -0
- data/test/omniauth/url_helpers_test.rb +52 -0
- data/test/orm/active_record.rb +10 -0
- data/test/orm/mongoid.rb +15 -0
- data/test/rails_app/Rakefile +10 -0
- data/test/rails_app/app/active_record/admin.rb +7 -0
- data/test/rails_app/app/active_record/shim.rb +3 -0
- data/test/rails_app/app/active_record/user.rb +7 -0
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +7 -0
- data/test/rails_app/app/controllers/admins_controller.rb +12 -0
- data/test/rails_app/app/controllers/application_controller.rb +9 -0
- data/test/rails_app/app/controllers/home_controller.rb +26 -0
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +3 -0
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +3 -0
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +15 -0
- data/test/rails_app/app/controllers/users_controller.rb +24 -0
- data/test/rails_app/app/helpers/application_helper.rb +4 -0
- data/test/rails_app/app/mailers/users/mailer.rb +9 -0
- data/test/rails_app/app/mongoid/admin.rb +28 -0
- data/test/rails_app/app/mongoid/shim.rb +25 -0
- data/test/rails_app/app/mongoid/user.rb +43 -0
- data/test/rails_app/app/views/admins/index.html.erb +1 -0
- data/test/rails_app/app/views/admins/sessions/new.html.erb +2 -0
- data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -0
- data/test/rails_app/app/views/home/index.html.erb +1 -0
- data/test/rails_app/app/views/home/join.html.erb +1 -0
- data/test/rails_app/app/views/home/private.html.erb +1 -0
- data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -0
- data/test/rails_app/app/views/layouts/application.html.erb +24 -0
- data/test/rails_app/app/views/users/index.html.erb +1 -0
- data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +1 -0
- data/test/rails_app/app/views/users/sessions/new.html.erb +1 -0
- data/test/rails_app/config/application.rb +42 -0
- data/test/rails_app/config/boot.rb +9 -0
- data/test/rails_app/config/database.yml +18 -0
- data/test/rails_app/config/environment.rb +6 -0
- data/test/rails_app/config/environments/development.rb +19 -0
- data/test/rails_app/config/environments/production.rb +34 -0
- data/test/rails_app/config/environments/test.rb +34 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +8 -0
- data/test/rails_app/config/initializers/devise.rb +179 -0
- data/test/rails_app/config/initializers/inflections.rb +3 -0
- data/test/rails_app/config/initializers/secret_token.rb +3 -0
- data/test/rails_app/config/routes.rb +101 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +75 -0
- data/test/rails_app/db/schema.rb +53 -0
- data/test/rails_app/lib/shared_admin.rb +15 -0
- data/test/rails_app/lib/shared_user.rb +27 -0
- data/test/rails_app/public/404.html +26 -0
- data/test/rails_app/public/422.html +26 -0
- data/test/rails_app/public/500.html +26 -0
- data/test/rails_app/public/favicon.ico +0 -0
- data/test/rails_app/script/rails +10 -0
- data/test/routes_test.rb +249 -0
- data/test/support/assertions.rb +41 -0
- data/test/support/helpers.rb +92 -0
- data/test/support/integration.rb +93 -0
- data/test/support/locale/en.yml +4 -0
- data/test/support/webrat/integrations/rails.rb +25 -0
- data/test/test_helper.rb +28 -0
- data/test/test_helpers_test.rb +152 -0
- metadata +407 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
Rails.application.routes.draw do
|
3
|
+
# Resources for testing
|
4
|
+
resources :users, :only => [:index] do
|
5
|
+
get :expire, :on => :member
|
6
|
+
get :accept, :on => :member
|
7
|
+
|
8
|
+
authenticate do
|
9
|
+
post :exhibit, :on => :member
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
resources :admins, :only => [:index] do
|
14
|
+
get :expire, :on => :member
|
15
|
+
end
|
16
|
+
|
17
|
+
# Users scope
|
18
|
+
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
|
19
|
+
|
20
|
+
as :user do
|
21
|
+
match "/as/sign_in", :to => "devise/sessions#new"
|
22
|
+
end
|
23
|
+
|
24
|
+
match "/sign_in", :to => "devise/sessions#new"
|
25
|
+
|
26
|
+
# Admin scope
|
27
|
+
devise_for :admin, :path => "admin_area", :controllers => { :sessions => :"admins/sessions" }, :skip => :passwords
|
28
|
+
|
29
|
+
match "/admin_area/home", :to => "admins#index", :as => :admin_root
|
30
|
+
match "/anywhere", :to => "foo#bar", :as => :new_admin_password
|
31
|
+
|
32
|
+
authenticate(:admin) do
|
33
|
+
match "/private", :to => "home#private", :as => :private
|
34
|
+
end
|
35
|
+
|
36
|
+
authenticate(:admin, lambda { |admin| admin.active? }) do
|
37
|
+
match "/private/active", :to => "home#private", :as => :private_active
|
38
|
+
end
|
39
|
+
|
40
|
+
authenticated :admin do
|
41
|
+
match "/dashboard", :to => "home#admin_dashboard"
|
42
|
+
end
|
43
|
+
|
44
|
+
authenticated :admin, lambda { |admin| admin.active? } do
|
45
|
+
match "/dashboard/active", :to => "home#admin_dashboard"
|
46
|
+
end
|
47
|
+
|
48
|
+
authenticated do
|
49
|
+
match "/dashboard", :to => "home#user_dashboard"
|
50
|
+
end
|
51
|
+
|
52
|
+
unauthenticated do
|
53
|
+
match "/join", :to => "home#join"
|
54
|
+
end
|
55
|
+
|
56
|
+
# Routes for constraints testing
|
57
|
+
devise_for :headquarters_admin, :class_name => "Admin", :path => "headquarters", :constraints => {:host => /192\.168\.1\.\d\d\d/}
|
58
|
+
|
59
|
+
constraints(:host => /192\.168\.1\.\d\d\d/) do
|
60
|
+
devise_for :homebase_admin, :class_name => "Admin", :path => "homebase"
|
61
|
+
end
|
62
|
+
|
63
|
+
devise_for :skip_admin, :class_name => "Admin", :skip => :all
|
64
|
+
|
65
|
+
# Routes for format=false testing
|
66
|
+
devise_for :htmlonly_admin, :class_name => "Admin", :skip => [:confirmations, :unlocks], :path => "htmlonly_admin", :format => false, :skip_helpers => [:confirmations, :unlocks]
|
67
|
+
devise_for :htmlonly_users, :class_name => "User", :only => [:confirmations, :unlocks], :path => "htmlonly_users", :format => false, :skip_helpers => true
|
68
|
+
|
69
|
+
# Other routes for routing_test.rb
|
70
|
+
devise_for :reader, :class_name => "User", :only => :passwords
|
71
|
+
|
72
|
+
scope :host => "sub.example.com" do
|
73
|
+
devise_for :sub_admin, :class_name => "Admin"
|
74
|
+
end
|
75
|
+
|
76
|
+
namespace :publisher, :path_names => { :sign_in => "i_dont_care", :sign_out => "get_out" } do
|
77
|
+
devise_for :accounts, :class_name => "Admin", :path_names => { :sign_in => "get_in" }
|
78
|
+
end
|
79
|
+
|
80
|
+
scope ":locale", :module => :invalid do
|
81
|
+
devise_for :accounts, :singular => "manager", :class_name => "Admin",
|
82
|
+
:path_names => {
|
83
|
+
:sign_in => "login", :sign_out => "logout",
|
84
|
+
:password => "secret", :confirmation => "verification",
|
85
|
+
:unlock => "unblock", :sign_up => "register",
|
86
|
+
:registration => "management", :cancel => "giveup"
|
87
|
+
}, :failure_app => lambda { |env| [404, {"Content-Type" => "text/plain"}, ["Oops, not found"]] }, :module => :devise
|
88
|
+
end
|
89
|
+
|
90
|
+
namespace :sign_out_via, :module => "devise" do
|
91
|
+
devise_for :deletes, :sign_out_via => :delete, :class_name => "Admin"
|
92
|
+
devise_for :posts, :sign_out_via => :post, :class_name => "Admin"
|
93
|
+
devise_for :delete_or_posts, :sign_out_via => [:delete, :post], :class_name => "Admin"
|
94
|
+
end
|
95
|
+
|
96
|
+
match "/set", :to => "home#set"
|
97
|
+
match "/unauthenticated", :to => "home#unauthenticated"
|
98
|
+
match "/custom_strategy/new"
|
99
|
+
|
100
|
+
root :to => "home#index"
|
101
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class CreateTables < ActiveRecord::Migration
|
3
|
+
def self.up
|
4
|
+
create_table :users do |t|
|
5
|
+
t.string :username
|
6
|
+
t.string :facebook_token
|
7
|
+
|
8
|
+
## Database authenticatable
|
9
|
+
t.string :email, :null => false, :default => ""
|
10
|
+
t.string :encrypted_password, :null => false, :default => ""
|
11
|
+
|
12
|
+
## Recoverable
|
13
|
+
t.string :reset_password_token
|
14
|
+
t.datetime :reset_password_sent_at
|
15
|
+
|
16
|
+
## Rememberable
|
17
|
+
t.datetime :remember_created_at
|
18
|
+
|
19
|
+
## Trackable
|
20
|
+
t.integer :sign_in_count, :default => 0
|
21
|
+
t.datetime :current_sign_in_at
|
22
|
+
t.datetime :last_sign_in_at
|
23
|
+
t.string :current_sign_in_ip
|
24
|
+
t.string :last_sign_in_ip
|
25
|
+
|
26
|
+
## Confirmable
|
27
|
+
t.string :confirmation_token
|
28
|
+
t.datetime :confirmed_at
|
29
|
+
t.datetime :confirmation_sent_at
|
30
|
+
# t.string :unconfirmed_email # Only if using reconfirmable
|
31
|
+
|
32
|
+
## Lockable
|
33
|
+
t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
|
34
|
+
t.string :unlock_token # Only if unlock strategy is :email or :both
|
35
|
+
t.datetime :locked_at
|
36
|
+
|
37
|
+
## Token authenticatable
|
38
|
+
t.string :authentication_token
|
39
|
+
|
40
|
+
t.timestamps
|
41
|
+
end
|
42
|
+
|
43
|
+
create_table :admins do |t|
|
44
|
+
## Database authenticatable
|
45
|
+
t.string :email, :null => true
|
46
|
+
t.string :encrypted_password, :null => true
|
47
|
+
|
48
|
+
## Recoverable
|
49
|
+
t.string :reset_password_token
|
50
|
+
t.datetime :reset_password_sent_at
|
51
|
+
|
52
|
+
## Rememberable
|
53
|
+
t.datetime :remember_created_at
|
54
|
+
|
55
|
+
## Confirmable
|
56
|
+
t.string :confirmation_token
|
57
|
+
t.datetime :confirmed_at
|
58
|
+
t.datetime :confirmation_sent_at
|
59
|
+
t.string :unconfirmed_email # Only if using reconfirmable
|
60
|
+
|
61
|
+
## Lockable
|
62
|
+
t.datetime :locked_at
|
63
|
+
|
64
|
+
## Attribute for testing route blocks
|
65
|
+
t.boolean :active, :default => false
|
66
|
+
|
67
|
+
t.timestamps
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.down
|
72
|
+
drop_table :users
|
73
|
+
drop_table :admins
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 20100401102949) do
|
15
|
+
|
16
|
+
create_table "admins", :force => true do |t|
|
17
|
+
t.string "email"
|
18
|
+
t.string "encrypted_password", :limit => 128
|
19
|
+
t.string "password_salt"
|
20
|
+
t.string "remember_token"
|
21
|
+
t.datetime "remember_created_at"
|
22
|
+
t.string "reset_password_token"
|
23
|
+
t.integer "failed_attempts", :default => 0
|
24
|
+
t.string "unlock_token"
|
25
|
+
t.datetime "locked_at"
|
26
|
+
t.datetime "created_at"
|
27
|
+
t.datetime "updated_at"
|
28
|
+
end
|
29
|
+
|
30
|
+
create_table "users", :force => true do |t|
|
31
|
+
t.string "username"
|
32
|
+
t.string "facebook_token"
|
33
|
+
t.string "email", :default => "", :null => false
|
34
|
+
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
35
|
+
t.string "confirmation_token"
|
36
|
+
t.datetime "confirmed_at"
|
37
|
+
t.datetime "confirmation_sent_at"
|
38
|
+
t.string "reset_password_token"
|
39
|
+
t.datetime "remember_created_at"
|
40
|
+
t.integer "sign_in_count", :default => 0
|
41
|
+
t.datetime "current_sign_in_at"
|
42
|
+
t.datetime "last_sign_in_at"
|
43
|
+
t.string "current_sign_in_ip"
|
44
|
+
t.string "last_sign_in_ip"
|
45
|
+
t.integer "failed_attempts", :default => 0
|
46
|
+
t.string "unlock_token"
|
47
|
+
t.datetime "locked_at"
|
48
|
+
t.string "authentication_token"
|
49
|
+
t.datetime "created_at"
|
50
|
+
t.datetime "updated_at"
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module SharedAdmin
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
devise :database_authenticatable, :registerable,
|
7
|
+
:timeoutable, :recoverable, :lockable, :confirmable,
|
8
|
+
:unlock_strategy => :time, :lock_strategy => :none,
|
9
|
+
:allow_unconfirmed_access_for => 2.weeks, :reconfirmable => true
|
10
|
+
|
11
|
+
validates_length_of :reset_password_token, :minimum => 3, :allow_blank => true
|
12
|
+
validates_uniqueness_of :email, :allow_blank => true, :if => :email_changed?
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module SharedUser
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
devise :database_authenticatable, :confirmable, :lockable, :recoverable,
|
7
|
+
:registerable, :rememberable, :timeoutable, :token_authenticatable,
|
8
|
+
:trackable, :validatable, :omniauthable
|
9
|
+
|
10
|
+
attr_accessor :other_key
|
11
|
+
attr_accessible :username, :email, :password, :password_confirmation, :remember_me, :confirmation_sent_at
|
12
|
+
|
13
|
+
# They need to be included after Devise is called.
|
14
|
+
extend ExtendMethods
|
15
|
+
end
|
16
|
+
|
17
|
+
module ExtendMethods
|
18
|
+
def new_with_session(params, session)
|
19
|
+
super.tap do |user|
|
20
|
+
if data = session["devise.facebook_data"]
|
21
|
+
user.email = data["email"]
|
22
|
+
user.confirmed_at = Time.now
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
ENV_PATH = File.expand_path('../../config/environment', __FILE__)
|
5
|
+
BOOT_PATH = File.expand_path('../../config/boot', __FILE__)
|
6
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
7
|
+
ROOT_PATH = File.expand_path('../..', __FILE__)
|
8
|
+
|
9
|
+
require BOOT_PATH
|
10
|
+
require 'rails/commands'
|
data/test/routes_test.rb
ADDED
@@ -0,0 +1,249 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class DefaultRoutingTest < ActionController::TestCase
|
5
|
+
test 'map new user session' do
|
6
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, {:path => 'users/sign_in', :method => :get})
|
7
|
+
assert_named_route "/users/sign_in", :new_user_session_path
|
8
|
+
end
|
9
|
+
|
10
|
+
test 'map create user session' do
|
11
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'create'}, {:path => 'users/sign_in', :method => :post})
|
12
|
+
assert_named_route "/users/sign_in", :user_session_path
|
13
|
+
end
|
14
|
+
|
15
|
+
test 'map destroy user session' do
|
16
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => 'users/sign_out', :method => :get})
|
17
|
+
assert_named_route "/users/sign_out", :destroy_user_session_path
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'map new user confirmation' do
|
21
|
+
assert_recognizes({:controller => 'devise/confirmations', :action => 'new'}, 'users/confirmation/new')
|
22
|
+
assert_named_route "/users/confirmation/new", :new_user_confirmation_path
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'map create user confirmation' do
|
26
|
+
assert_recognizes({:controller => 'devise/confirmations', :action => 'create'}, {:path => 'users/confirmation', :method => :post})
|
27
|
+
assert_named_route "/users/confirmation", :user_confirmation_path
|
28
|
+
end
|
29
|
+
|
30
|
+
test 'map show user confirmation' do
|
31
|
+
assert_recognizes({:controller => 'devise/confirmations', :action => 'show'}, {:path => 'users/confirmation', :method => :get})
|
32
|
+
end
|
33
|
+
|
34
|
+
test 'map new user password' do
|
35
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'new'}, 'users/password/new')
|
36
|
+
assert_named_route "/users/password/new", :new_user_password_path
|
37
|
+
end
|
38
|
+
|
39
|
+
test 'map create user password' do
|
40
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'create'}, {:path => 'users/password', :method => :post})
|
41
|
+
assert_named_route "/users/password", :user_password_path
|
42
|
+
end
|
43
|
+
|
44
|
+
test 'map edit user password' do
|
45
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'edit'}, 'users/password/edit')
|
46
|
+
assert_named_route "/users/password/edit", :edit_user_password_path
|
47
|
+
end
|
48
|
+
|
49
|
+
test 'map update user password' do
|
50
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'update'}, {:path => 'users/password', :method => :put})
|
51
|
+
end
|
52
|
+
|
53
|
+
test 'map new user unlock' do
|
54
|
+
assert_recognizes({:controller => 'devise/unlocks', :action => 'new'}, 'users/unlock/new')
|
55
|
+
assert_named_route "/users/unlock/new", :new_user_unlock_path
|
56
|
+
end
|
57
|
+
|
58
|
+
test 'map create user unlock' do
|
59
|
+
assert_recognizes({:controller => 'devise/unlocks', :action => 'create'}, {:path => 'users/unlock', :method => :post})
|
60
|
+
assert_named_route "/users/unlock", :user_unlock_path
|
61
|
+
end
|
62
|
+
|
63
|
+
test 'map show user unlock' do
|
64
|
+
assert_recognizes({:controller => 'devise/unlocks', :action => 'show'}, {:path => 'users/unlock', :method => :get})
|
65
|
+
end
|
66
|
+
|
67
|
+
test 'map new user registration' do
|
68
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, 'users/sign_up')
|
69
|
+
assert_named_route "/users/sign_up", :new_user_registration_path
|
70
|
+
end
|
71
|
+
|
72
|
+
test 'map create user registration' do
|
73
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'create'}, {:path => 'users', :method => :post})
|
74
|
+
assert_named_route "/users", :user_registration_path
|
75
|
+
end
|
76
|
+
|
77
|
+
test 'map edit user registration' do
|
78
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'edit'}, {:path => 'users/edit', :method => :get})
|
79
|
+
assert_named_route "/users/edit", :edit_user_registration_path
|
80
|
+
end
|
81
|
+
|
82
|
+
test 'map update user registration' do
|
83
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'update'}, {:path => 'users', :method => :put})
|
84
|
+
end
|
85
|
+
|
86
|
+
test 'map destroy user registration' do
|
87
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'destroy'}, {:path => 'users', :method => :delete})
|
88
|
+
end
|
89
|
+
|
90
|
+
test 'map cancel user registration' do
|
91
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'cancel'}, {:path => 'users/cancel', :method => :get})
|
92
|
+
assert_named_route "/users/cancel", :cancel_user_registration_path
|
93
|
+
end
|
94
|
+
|
95
|
+
test 'map omniauth callbacks' do
|
96
|
+
assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'facebook'}, {:path => 'users/auth/facebook/callback', :method => :get})
|
97
|
+
assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'facebook'}, {:path => 'users/auth/facebook/callback', :method => :post})
|
98
|
+
assert_named_route "/users/auth/facebook/callback", :user_omniauth_callback_path, :facebook
|
99
|
+
|
100
|
+
# named open_id
|
101
|
+
assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'google'}, {:path => 'users/auth/google/callback', :method => :get})
|
102
|
+
assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'google'}, {:path => 'users/auth/google/callback', :method => :post})
|
103
|
+
assert_named_route "/users/auth/google/callback", :user_omniauth_callback_path, :google
|
104
|
+
|
105
|
+
assert_raise ActionController::RoutingError do
|
106
|
+
assert_recognizes({:controller => 'ysers/omniauth_callbacks', :action => 'twitter'}, {:path => 'users/auth/twitter/callback', :method => :get})
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
protected
|
111
|
+
|
112
|
+
def assert_named_route(result, *args)
|
113
|
+
assert_equal result, @routes.url_helpers.send(*args)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
class CustomizedRoutingTest < ActionController::TestCase
|
118
|
+
test 'map admin with :path option' do
|
119
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'admin_area/sign_up', :method => :get})
|
120
|
+
end
|
121
|
+
|
122
|
+
test 'map admin with :controllers option' do
|
123
|
+
assert_recognizes({:controller => 'admins/sessions', :action => 'new'}, {:path => 'admin_area/sign_in', :method => :get})
|
124
|
+
end
|
125
|
+
|
126
|
+
test 'does not map admin password' do
|
127
|
+
assert_raise ActionController::RoutingError do
|
128
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'new'}, 'admin_area/password/new')
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
test 'subdomain admin' do
|
133
|
+
assert_recognizes({"host"=>"sub.example.com", :controller => 'devise/sessions', :action => 'new'}, {:host => "sub.example.com", :path => '/sub_admin/sign_in', :method => :get})
|
134
|
+
end
|
135
|
+
|
136
|
+
test 'does only map reader password' do
|
137
|
+
assert_raise ActionController::RoutingError do
|
138
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, 'reader/sessions/new')
|
139
|
+
end
|
140
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'new'}, 'reader/password/new')
|
141
|
+
end
|
142
|
+
|
143
|
+
test 'map account with custom path name for session sign in' do
|
144
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'new', :locale => 'en'}, '/en/accounts/login')
|
145
|
+
end
|
146
|
+
|
147
|
+
test 'map account with custom path name for session sign out' do
|
148
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy', :locale => 'en'}, '/en/accounts/logout')
|
149
|
+
end
|
150
|
+
|
151
|
+
test 'map account with custom path name for password' do
|
152
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'new', :locale => 'en'}, '/en/accounts/secret/new')
|
153
|
+
end
|
154
|
+
|
155
|
+
test 'map account with custom path name for registration' do
|
156
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new', :locale => 'en'}, '/en/accounts/management/register')
|
157
|
+
end
|
158
|
+
|
159
|
+
test 'map account with custom path name for cancel registration' do
|
160
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'cancel', :locale => 'en'}, '/en/accounts/management/giveup')
|
161
|
+
end
|
162
|
+
|
163
|
+
test 'map deletes with :sign_out_via option' do
|
164
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/deletes/sign_out', :method => :delete})
|
165
|
+
assert_raise ActionController::RoutingError do
|
166
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/deletes/sign_out', :method => :get})
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
test 'map posts with :sign_out_via option' do
|
171
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/posts/sign_out', :method => :post})
|
172
|
+
assert_raise ActionController::RoutingError do
|
173
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/posts/sign_out', :method => :get})
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
test 'map delete_or_posts with :sign_out_via option' do
|
178
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :post})
|
179
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :delete})
|
180
|
+
assert_raise ActionController::RoutingError do
|
181
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :get})
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
test 'map with constraints defined in hash' do
|
186
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://192.168.1.100/headquarters/sign_up', :method => :get})
|
187
|
+
assert_raise ActionController::RoutingError do
|
188
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://10.0.0.100/headquarters/sign_up', :method => :get})
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
test 'map with constraints defined in block' do
|
193
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://192.168.1.100/homebase/sign_up', :method => :get})
|
194
|
+
assert_raise ActionController::RoutingError do
|
195
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://10.0.0.100//homebase/sign_up', :method => :get})
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
test 'map with format false for sessions' do
|
200
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, {:path => '/htmlonly_admin/sign_in', :method => :get})
|
201
|
+
assert_raise ActionController::RoutingError do
|
202
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, {:path => '/htmlonly_admin/sign_in.xml', :method => :get})
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
test 'map with format false for passwords' do
|
207
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'create'}, {:path => '/htmlonly_admin/password', :method => :post})
|
208
|
+
assert_raise ActionController::RoutingError do
|
209
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'create'}, {:path => '/htmlonly_admin/password.xml', :method => :post})
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
test 'map with format false for registrations' do
|
214
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => '/htmlonly_admin/sign_up', :method => :get})
|
215
|
+
assert_raise ActionController::RoutingError do
|
216
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => '/htmlonly_admin/sign_up.xml', :method => :get})
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
test 'map with format false for confirmations' do
|
221
|
+
assert_recognizes({:controller => 'devise/confirmations', :action => 'show'}, {:path => '/htmlonly_users/confirmation', :method => :get})
|
222
|
+
assert_raise ActionController::RoutingError do
|
223
|
+
assert_recognizes({:controller => 'devise/confirmations', :action => 'show'}, {:path => '/htmlonly_users/confirmation.xml', :method => :get})
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
test 'map with format false for unlocks' do
|
228
|
+
assert_recognizes({:controller => 'devise/unlocks', :action => 'show'}, {:path => '/htmlonly_users/unlock', :method => :get})
|
229
|
+
assert_raise ActionController::RoutingError do
|
230
|
+
assert_recognizes({:controller => 'devise/unlocks', :action => 'show'}, {:path => '/htmlonly_users/unlock.xml', :method => :get})
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
test 'map with format false is not permanent' do
|
235
|
+
assert_equal "/set.xml", @routes.url_helpers.set_path(:xml)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
class ScopedRoutingTest < ActionController::TestCase
|
240
|
+
test 'map publisher account' do
|
241
|
+
assert_recognizes({:controller => 'publisher/registrations', :action => 'new'}, {:path => '/publisher/accounts/sign_up', :method => :get})
|
242
|
+
assert_equal '/publisher/accounts/sign_up', @routes.url_helpers.new_publisher_account_registration_path
|
243
|
+
end
|
244
|
+
|
245
|
+
test 'map publisher account merges path names' do
|
246
|
+
assert_recognizes({:controller => 'publisher/sessions', :action => 'new'}, {:path => '/publisher/accounts/get_in', :method => :get})
|
247
|
+
assert_equal '/publisher/accounts/get_in', @routes.url_helpers.new_publisher_account_session_path
|
248
|
+
end
|
249
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'active_support/test_case'
|
3
|
+
|
4
|
+
class ActiveSupport::TestCase
|
5
|
+
def assert_not(assertion)
|
6
|
+
assert !assertion
|
7
|
+
end
|
8
|
+
|
9
|
+
def assert_blank(assertion)
|
10
|
+
assert assertion.blank?
|
11
|
+
end
|
12
|
+
|
13
|
+
def assert_not_blank(assertion)
|
14
|
+
assert !assertion.blank?
|
15
|
+
end
|
16
|
+
alias :assert_present :assert_not_blank
|
17
|
+
|
18
|
+
def assert_email_sent(address = nil, &block)
|
19
|
+
assert_difference('ActionMailer::Base.deliveries.size', &block)
|
20
|
+
if address.present?
|
21
|
+
assert_equal address, ActionMailer::Base.deliveries.last['to'].to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def assert_email_not_sent(&block)
|
26
|
+
assert_no_difference('ActionMailer::Base.deliveries.size', &block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def assert_same_content(result, expected)
|
30
|
+
assert expected.size == result.size, "the arrays doesn't have the same size"
|
31
|
+
expected.each do |element|
|
32
|
+
assert result.include?(element), "The array doesn't include '#{element}'."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def assert_raise_with_message(exception_klass, message, &block)
|
37
|
+
exception = assert_raise exception_klass, &block
|
38
|
+
assert_equal exception.message, message,
|
39
|
+
"The expected message was #{message} but your exception throwed #{exception.message}"
|
40
|
+
end
|
41
|
+
end
|