devise 1.5.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +98 -71
- data/MIT-LICENSE +1 -1
- data/README.rdoc +4 -2
- data/app/controllers/devise/confirmations_controller.rb +3 -6
- data/app/controllers/devise/omniauth_callbacks_controller.rb +1 -3
- data/app/controllers/devise/passwords_controller.rb +3 -6
- data/app/controllers/devise/registrations_controller.rb +40 -42
- data/app/controllers/devise/sessions_controller.rb +2 -3
- data/app/controllers/devise/unlocks_controller.rb +4 -7
- data/app/controllers/devise_controller.rb +169 -0
- data/app/views/devise/_links.erb +25 -0
- data/app/views/devise/confirmations/new.html.erb +1 -1
- data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
- data/app/views/devise/passwords/edit.html.erb +1 -1
- data/app/views/devise/passwords/new.html.erb +1 -1
- data/app/views/devise/registrations/new.html.erb +1 -1
- data/app/views/devise/sessions/new.html.erb +1 -1
- data/app/views/devise/shared/_links.erb +3 -25
- data/app/views/devise/unlocks/new.html.erb +1 -1
- data/config/locales/en.yml +5 -6
- data/lib/devise/controllers/helpers.rb +8 -2
- data/lib/devise/controllers/scoped_views.rb +0 -16
- data/lib/devise/controllers/url_helpers.rb +16 -2
- data/lib/devise/failure_app.rb +43 -8
- data/lib/devise/models/authenticatable.rb +22 -1
- data/lib/devise/models/confirmable.rb +80 -22
- data/lib/devise/models/database_authenticatable.rb +0 -11
- data/lib/devise/models/lockable.rb +1 -1
- data/lib/devise/models/recoverable.rb +5 -5
- data/lib/devise/models/rememberable.rb +5 -20
- data/lib/devise/models/serializable.rb +5 -2
- data/lib/devise/models/timeoutable.rb +1 -3
- data/lib/devise/models/token_authenticatable.rb +1 -4
- data/lib/devise/models/validatable.rb +1 -1
- data/lib/devise/models.rb +1 -1
- data/lib/devise/modules.rb +2 -2
- data/lib/devise/orm/active_record.rb +6 -0
- data/lib/devise/param_filter.rb +1 -1
- data/lib/devise/path_checker.rb +5 -1
- data/lib/devise/rails/routes.rb +16 -10
- data/lib/devise/rails/warden_compat.rb +0 -83
- data/lib/devise/rails.rb +61 -0
- data/lib/devise/schema.rb +5 -0
- data/lib/devise/strategies/authenticatable.rb +14 -10
- data/lib/devise/strategies/token_authenticatable.rb +3 -3
- data/lib/devise/version.rb +1 -1
- data/lib/devise.rb +56 -33
- data/lib/generators/active_record/devise_generator.rb +40 -2
- data/lib/generators/active_record/templates/migration.rb +1 -19
- data/lib/generators/active_record/templates/migration_existing.rb +1 -9
- data/lib/generators/devise/views_generator.rb +6 -14
- data/lib/generators/mongoid/devise_generator.rb +43 -0
- data/lib/generators/templates/devise.rb +26 -12
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +1 -1
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +1 -1
- data/lib/generators/templates/simple_form_for/passwords/new.html.erb +1 -1
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +1 -1
- data/lib/generators/templates/simple_form_for/sessions/new.html.erb +1 -1
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +1 -1
- data/test/controllers/internal_helpers_test.rb +5 -4
- data/test/devise_test.rb +2 -2
- data/test/failure_app_test.rb +24 -20
- data/test/generators/active_record_generator_test.rb +3 -13
- data/test/generators/views_generator_test.rb +1 -1
- data/test/integration/authenticatable_test.rb +4 -7
- data/test/integration/confirmable_test.rb +55 -3
- data/test/integration/http_authenticatable_test.rb +20 -5
- data/test/integration/lockable_test.rb +26 -14
- data/test/integration/registerable_test.rb +33 -2
- data/test/integration/rememberable_test.rb +0 -50
- data/test/integration/timeoutable_test.rb +18 -4
- data/test/integration/token_authenticatable_test.rb +5 -5
- data/test/integration/trackable_test.rb +6 -6
- data/test/mapping_test.rb +2 -3
- data/test/models/confirmable_test.rb +101 -8
- data/test/models/database_authenticatable_test.rb +6 -0
- data/test/models/encryptable_test.rb +1 -1
- data/test/models/lockable_test.rb +13 -0
- data/test/models/recoverable_test.rb +0 -27
- data/test/models/rememberable_test.rb +41 -160
- data/test/models/serializable_test.rb +1 -1
- data/test/models_test.rb +7 -7
- data/test/rails_app/app/mongoid/admin.rb +22 -1
- data/test/rails_app/app/mongoid/user.rb +35 -0
- data/test/rails_app/config/initializers/devise.rb +6 -7
- data/test/rails_app/config/routes.rb +3 -5
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +58 -12
- data/test/rails_app/lib/shared_admin.rb +6 -2
- data/test/rails_app/log/development.log +13 -0
- data/test/rails_app/log/test.log +319550 -0
- data/test/support/assertions.rb +4 -1
- data/test/support/helpers.rb +0 -17
- data/test/support/integration.rb +3 -1
- data/test/test_helpers_test.rb +2 -2
- data/test/tmp/app/views/devise/_links.erb +25 -0
- data/test/tmp/app/views/devise/confirmations/new.html.erb +15 -0
- data/test/tmp/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/test/tmp/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/test/tmp/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/test/tmp/app/views/devise/passwords/edit.html.erb +19 -0
- data/test/tmp/app/views/devise/passwords/new.html.erb +15 -0
- data/test/tmp/app/views/devise/registrations/edit.html.erb +22 -0
- data/test/tmp/app/views/devise/registrations/new.html.erb +17 -0
- data/test/tmp/app/views/devise/sessions/new.html.erb +15 -0
- data/test/tmp/app/views/devise/unlocks/new.html.erb +15 -0
- data/test/tmp/app/views/users/_links.erb +25 -0
- data/test/tmp/app/views/users/confirmations/new.html.erb +15 -0
- data/test/tmp/app/views/users/mailer/confirmation_instructions.html.erb +5 -0
- data/test/tmp/app/views/users/mailer/reset_password_instructions.html.erb +8 -0
- data/test/tmp/app/views/users/mailer/unlock_instructions.html.erb +7 -0
- data/test/tmp/app/views/users/passwords/edit.html.erb +19 -0
- data/test/tmp/app/views/users/passwords/new.html.erb +15 -0
- data/test/tmp/app/views/users/registrations/edit.html.erb +22 -0
- data/test/tmp/app/views/users/registrations/new.html.erb +17 -0
- data/test/tmp/app/views/users/sessions/new.html.erb +15 -0
- data/test/tmp/app/views/users/unlocks/new.html.erb +15 -0
- metadata +78 -26
- data/.gitignore +0 -12
- data/.travis.yml +0 -13
- data/Gemfile +0 -35
- data/Rakefile +0 -34
- data/devise.gemspec +0 -25
- data/lib/devise/controllers/internal_helpers.rb +0 -154
- data/lib/devise/controllers/shared_helpers.rb +0 -26
- data/test/schema_test.rb +0 -33
|
@@ -12,6 +12,9 @@ Devise.setup do |config|
|
|
|
12
12
|
# Configure the class responsible to send e-mails.
|
|
13
13
|
# config.mailer = "Devise::Mailer"
|
|
14
14
|
|
|
15
|
+
# Disable apply schema
|
|
16
|
+
config.apply_schema = false
|
|
17
|
+
|
|
15
18
|
# ==> ORM configuration
|
|
16
19
|
# Load and configure the ORM. Supports :active_record (default) and
|
|
17
20
|
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
|
@@ -60,16 +63,16 @@ Devise.setup do |config|
|
|
|
60
63
|
# ==> Configuration for :database_authenticatable
|
|
61
64
|
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
|
62
65
|
# using other encryptors, it sets how many times you want the password re-encrypted.
|
|
63
|
-
config.stretches = 10
|
|
66
|
+
config.stretches = Rails.env.test? ? 1 : 10
|
|
64
67
|
|
|
65
68
|
# ==> Configuration for :confirmable
|
|
66
69
|
# The time you want to give your user to confirm his account. During this time
|
|
67
70
|
# he will be able to access your application without confirming. Default is nil.
|
|
68
|
-
# When
|
|
71
|
+
# When allow_unconfirmed_access_for is zero, the user won't be able to sign in without confirming.
|
|
69
72
|
# You can use this to let your user access some features of your application
|
|
70
73
|
# without confirming the account, but blocking it after a certain period
|
|
71
74
|
# (ie 2 days).
|
|
72
|
-
# config.
|
|
75
|
+
# config.allow_unconfirmed_access_for = 2.days
|
|
73
76
|
|
|
74
77
|
# Defines which key will be used when confirming an account
|
|
75
78
|
# config.confirmation_keys = [ :email ]
|
|
@@ -148,10 +151,6 @@ Devise.setup do |config|
|
|
|
148
151
|
# Defines name of the authentication token params key
|
|
149
152
|
# config.token_authentication_key = :auth_token
|
|
150
153
|
|
|
151
|
-
# If true, authentication through token does not store user in session and needs
|
|
152
|
-
# to be supplied on each request. Useful if you are using the token as API token.
|
|
153
|
-
# config.stateless_token = false
|
|
154
|
-
|
|
155
154
|
# ==> Scopes configuration
|
|
156
155
|
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
|
157
156
|
# "users/sessions/new". It's turned off by default because it's slower if you
|
|
@@ -12,9 +12,7 @@ Rails.application.routes.draw do
|
|
|
12
12
|
resources :admins, :only => [:index]
|
|
13
13
|
|
|
14
14
|
# Users scope
|
|
15
|
-
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
|
|
16
|
-
match "/devise_for/sign_in", :to => "devise/sessions#new"
|
|
17
|
-
end
|
|
15
|
+
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
|
|
18
16
|
|
|
19
17
|
as :user do
|
|
20
18
|
match "/as/sign_in", :to => "devise/sessions#new"
|
|
@@ -64,14 +62,14 @@ Rails.application.routes.draw do
|
|
|
64
62
|
devise_for :accounts, :class_name => "Admin", :path_names => { :sign_in => "get_in" }
|
|
65
63
|
end
|
|
66
64
|
|
|
67
|
-
scope ":locale" do
|
|
65
|
+
scope ":locale", :module => :invalid do
|
|
68
66
|
devise_for :accounts, :singular => "manager", :class_name => "Admin",
|
|
69
67
|
:path_names => {
|
|
70
68
|
:sign_in => "login", :sign_out => "logout",
|
|
71
69
|
:password => "secret", :confirmation => "verification",
|
|
72
70
|
:unlock => "unblock", :sign_up => "register",
|
|
73
71
|
:registration => "management", :cancel => "giveup"
|
|
74
|
-
}, :failure_app => lambda { |env| [404, {"Content-Type" => "text/plain"}, ["Oops, not found"]] }
|
|
72
|
+
}, :failure_app => lambda { |env| [404, {"Content-Type" => "text/plain"}, ["Oops, not found"]] }, :module => :devise
|
|
75
73
|
end
|
|
76
74
|
|
|
77
75
|
namespace :sign_out_via, :module => "devise" do
|
|
@@ -4,22 +4,68 @@ class CreateTables < ActiveRecord::Migration
|
|
|
4
4
|
t.string :username
|
|
5
5
|
t.string :facebook_token
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
t.
|
|
9
|
-
t.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
t.
|
|
13
|
-
t.
|
|
7
|
+
## Database authenticatable
|
|
8
|
+
t.string :email, :null => false, :default => ""
|
|
9
|
+
t.string :encrypted_password, :null => false, :default => ""
|
|
10
|
+
|
|
11
|
+
## Recoverable
|
|
12
|
+
t.string :reset_password_token
|
|
13
|
+
t.datetime :reset_password_sent_at
|
|
14
|
+
|
|
15
|
+
## Rememberable
|
|
16
|
+
t.datetime :remember_created_at
|
|
17
|
+
|
|
18
|
+
## Trackable
|
|
19
|
+
t.integer :sign_in_count, :default => 0
|
|
20
|
+
t.datetime :current_sign_in_at
|
|
21
|
+
t.datetime :last_sign_in_at
|
|
22
|
+
t.string :current_sign_in_ip
|
|
23
|
+
t.string :last_sign_in_ip
|
|
24
|
+
|
|
25
|
+
## Encryptable
|
|
26
|
+
# t.string :password_salt
|
|
27
|
+
|
|
28
|
+
## Confirmable
|
|
29
|
+
t.string :confirmation_token
|
|
30
|
+
t.datetime :confirmed_at
|
|
31
|
+
t.datetime :confirmation_sent_at
|
|
32
|
+
# t.string :unconfirmed_email # Only if using reconfirmable
|
|
33
|
+
|
|
34
|
+
## Lockable
|
|
35
|
+
t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
|
|
36
|
+
t.string :unlock_token # Only if unlock strategy is :email or :both
|
|
37
|
+
t.datetime :locked_at
|
|
38
|
+
|
|
39
|
+
## Token authenticatable
|
|
40
|
+
t.string :authentication_token
|
|
41
|
+
|
|
14
42
|
t.timestamps
|
|
15
43
|
end
|
|
16
44
|
|
|
17
45
|
create_table :admins do |t|
|
|
18
|
-
|
|
19
|
-
t.
|
|
20
|
-
t.
|
|
21
|
-
|
|
22
|
-
|
|
46
|
+
## Database authenticatable
|
|
47
|
+
t.string :email, :null => true
|
|
48
|
+
t.string :encrypted_password, :null => true
|
|
49
|
+
|
|
50
|
+
## Recoverable
|
|
51
|
+
t.string :reset_password_token
|
|
52
|
+
t.datetime :reset_password_sent_at
|
|
53
|
+
|
|
54
|
+
## Rememberable
|
|
55
|
+
t.datetime :remember_created_at
|
|
56
|
+
|
|
57
|
+
## Confirmable
|
|
58
|
+
t.string :confirmation_token
|
|
59
|
+
t.datetime :confirmed_at
|
|
60
|
+
t.datetime :confirmation_sent_at
|
|
61
|
+
t.string :unconfirmed_email # Only if using reconfirmable
|
|
62
|
+
|
|
63
|
+
## Encryptable
|
|
64
|
+
t.string :password_salt
|
|
65
|
+
|
|
66
|
+
## Lockable
|
|
67
|
+
t.datetime :locked_at
|
|
68
|
+
|
|
23
69
|
t.timestamps
|
|
24
70
|
end
|
|
25
71
|
end
|
|
@@ -3,8 +3,12 @@ module SharedAdmin
|
|
|
3
3
|
|
|
4
4
|
included do
|
|
5
5
|
devise :database_authenticatable, :encryptable, :registerable,
|
|
6
|
-
:timeoutable, :recoverable, :
|
|
7
|
-
:unlock_strategy => :time
|
|
6
|
+
:timeoutable, :recoverable, :lockable, :confirmable,
|
|
7
|
+
:unlock_strategy => :time, :lock_strategy => :none,
|
|
8
|
+
:allow_unconfirmed_access_for => 2.weeks, :reconfirmable => true
|
|
9
|
+
|
|
10
|
+
validates_length_of :reset_password_token, :minimum => 3, :allow_blank => true
|
|
11
|
+
validates_uniqueness_of :email, :allow_blank => true, :if => :email_changed?
|
|
8
12
|
end
|
|
9
13
|
|
|
10
14
|
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
|
2
|
+
[1m[35m (1.3ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
|
3
|
+
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
|
4
|
+
[1m[35m (1.1ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
|
5
|
+
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
|
6
|
+
Migrating to CreateTables (20100401102949)
|
|
7
|
+
[1m[35m (0.4ms)[0m CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar(255), "facebook_token" varchar(255), "email" varchar(255) DEFAULT '' NOT NULL, "encrypted_password" varchar(128) DEFAULT '' NOT NULL, "confirmation_token" varchar(255), "confirmed_at" datetime, "confirmation_sent_at" datetime, "reset_password_token" varchar(255), "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar(255), "last_sign_in_ip" varchar(255), "failed_attempts" integer DEFAULT 0, "unlock_token" varchar(255), "locked_at" datetime, "authentication_token" varchar(255), "created_at" datetime, "updated_at" datetime)
|
|
8
|
+
[1m[36m (0.1ms)[0m [1mCREATE TABLE "admins" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar(255), "encrypted_password" varchar(128), "password_salt" varchar(255), "remember_token" varchar(255), "remember_created_at" datetime, "reset_password_token" varchar(255), "reset_password_sent_at" datetime, "failed_attempts" integer DEFAULT 0, "unlock_token" varchar(255), "locked_at" datetime, "created_at" datetime, "updated_at" datetime) [0m
|
|
9
|
+
[1m[35m (0.1ms)[0m INSERT INTO "schema_migrations" ("version") VALUES ('20100401102949')
|
|
10
|
+
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
|
11
|
+
[1m[35m (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
|
12
|
+
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("admins")[0m
|
|
13
|
+
[1m[35m (0.0ms)[0m PRAGMA index_list("users")
|