devise 3.2.0 → 3.3.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.
Potentially problematic release.
This version of devise might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.travis.yml +18 -3
- data/CHANGELOG.md +82 -9
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +7 -9
- data/Gemfile.lock +102 -96
- data/MIT-LICENSE +1 -1
- data/README.md +94 -42
- data/Rakefile +1 -1
- data/app/controllers/devise/confirmations_controller.rb +5 -3
- data/app/controllers/devise/omniauth_callbacks_controller.rb +2 -2
- data/app/controllers/devise/passwords_controller.rb +5 -3
- data/app/controllers/devise/registrations_controller.rb +26 -10
- data/app/controllers/devise/sessions_controller.rb +39 -14
- data/app/controllers/devise/unlocks_controller.rb +4 -2
- data/app/controllers/devise_controller.rb +6 -6
- data/app/helpers/devise_helper.rb +2 -2
- data/app/views/devise/confirmations/new.html.erb +2 -2
- data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
- data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
- data/app/views/devise/mailer/unlock_instructions.html.erb +1 -1
- data/app/views/devise/passwords/edit.html.erb +3 -3
- data/app/views/devise/passwords/new.html.erb +2 -2
- data/app/views/devise/registrations/edit.html.erb +6 -6
- data/app/views/devise/registrations/new.html.erb +5 -5
- data/app/views/devise/sessions/new.html.erb +5 -5
- data/app/views/devise/shared/_links.erb +1 -1
- data/app/views/devise/unlocks/new.html.erb +2 -2
- data/config/locales/en.yml +17 -16
- data/devise.gemspec +2 -2
- data/gemfiles/{Gemfile.rails-3.2.x → Gemfile.rails-3.2-stable} +8 -10
- data/gemfiles/Gemfile.rails-3.2-stable.lock +166 -0
- data/gemfiles/Gemfile.rails-4.0-stable +29 -0
- data/gemfiles/Gemfile.rails-4.0-stable.lock +162 -0
- data/gemfiles/Gemfile.rails-head +32 -0
- data/gemfiles/Gemfile.rails-head.lock +190 -0
- data/lib/devise/controllers/helpers.rb +84 -29
- data/lib/devise/controllers/rememberable.rb +3 -3
- data/lib/devise/controllers/scoped_views.rb +1 -1
- data/lib/devise/controllers/sign_in_out.rb +9 -10
- data/lib/devise/controllers/store_location.rb +56 -0
- data/lib/devise/controllers/url_helpers.rb +3 -1
- data/lib/devise/failure_app.rb +12 -10
- data/lib/devise/hooks/activatable.rb +5 -6
- data/lib/devise/hooks/csrf_cleaner.rb +3 -1
- data/lib/devise/hooks/lockable.rb +1 -1
- data/lib/devise/hooks/proxy.rb +2 -2
- data/lib/devise/hooks/rememberable.rb +2 -2
- data/lib/devise/hooks/timeoutable.rb +10 -3
- data/lib/devise/hooks/trackable.rb +1 -1
- data/lib/devise/mailers/helpers.rb +8 -8
- data/lib/devise/mapping.rb +4 -1
- data/lib/devise/models/authenticatable.rb +5 -5
- data/lib/devise/models/confirmable.rb +14 -14
- data/lib/devise/models/database_authenticatable.rb +18 -5
- data/lib/devise/models/lockable.rb +14 -11
- data/lib/devise/models/omniauthable.rb +1 -1
- data/lib/devise/models/recoverable.rb +23 -7
- data/lib/devise/models/rememberable.rb +6 -6
- data/lib/devise/models/timeoutable.rb +2 -2
- data/lib/devise/models/trackable.rb +5 -2
- data/lib/devise/models/validatable.rb +6 -6
- data/lib/devise/modules.rb +10 -10
- data/lib/devise/omniauth/url_helpers.rb +2 -2
- data/lib/devise/orm/active_record.rb +1 -1
- data/lib/devise/orm/mongoid.rb +1 -1
- data/lib/devise/rails/routes.rb +107 -78
- data/lib/devise/rails.rb +7 -1
- data/lib/devise/strategies/authenticatable.rb +11 -4
- data/lib/devise/strategies/base.rb +1 -1
- data/lib/devise/strategies/database_authenticatable.rb +7 -4
- data/lib/devise/test_helpers.rb +2 -2
- data/lib/devise/time_inflector.rb +2 -2
- data/lib/devise/version.rb +1 -1
- data/lib/devise.rb +15 -10
- data/lib/generators/active_record/devise_generator.rb +27 -10
- data/lib/generators/active_record/templates/migration.rb +4 -4
- data/lib/generators/active_record/templates/migration_existing.rb +4 -4
- data/lib/generators/devise/devise_generator.rb +5 -3
- data/lib/generators/devise/install_generator.rb +5 -0
- data/lib/generators/devise/views_generator.rb +31 -18
- data/lib/generators/mongoid/devise_generator.rb +20 -19
- data/lib/generators/templates/README +4 -4
- data/lib/generators/templates/devise.rb +20 -11
- data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
- data/lib/generators/templates/markerb/reset_password_instructions.markerb +1 -1
- data/lib/generators/templates/markerb/unlock_instructions.markerb +1 -1
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +2 -2
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +4 -4
- data/lib/generators/templates/simple_form_for/passwords/new.html.erb +2 -2
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +6 -6
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +4 -4
- data/lib/generators/templates/simple_form_for/sessions/new.html.erb +4 -4
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +2 -2
- data/script/cached-bundle +49 -0
- data/script/s3-put +71 -0
- data/test/controllers/custom_registrations_controller_test.rb +35 -0
- data/test/controllers/helpers_test.rb +89 -31
- data/test/controllers/internal_helpers_test.rb +11 -8
- data/test/controllers/passwords_controller_test.rb +1 -1
- data/test/controllers/sessions_controller_test.rb +29 -25
- data/test/controllers/url_helpers_test.rb +4 -4
- data/test/delegator_test.rb +1 -1
- data/test/devise_test.rb +21 -8
- data/test/failure_app_test.rb +61 -25
- data/test/generators/active_record_generator_test.rb +10 -4
- data/test/generators/devise_generator_test.rb +2 -2
- data/test/generators/mongoid_generator_test.rb +3 -3
- data/test/generators/views_generator_test.rb +30 -1
- data/test/helpers/devise_helper_test.rb +14 -13
- data/test/integration/authenticatable_test.rb +61 -45
- data/test/integration/confirmable_test.rb +95 -55
- data/test/integration/database_authenticatable_test.rb +16 -16
- data/test/integration/http_authenticatable_test.rb +12 -12
- data/test/integration/lockable_test.rb +43 -43
- data/test/integration/omniauthable_test.rb +3 -3
- data/test/integration/recoverable_test.rb +53 -53
- data/test/integration/registerable_test.rb +90 -80
- data/test/integration/rememberable_test.rb +15 -15
- data/test/integration/timeoutable_test.rb +27 -16
- data/test/integration/trackable_test.rb +4 -4
- data/test/mailers/confirmation_instructions_test.rb +7 -7
- data/test/mailers/reset_password_instructions_test.rb +6 -6
- data/test/mailers/unlock_instructions_test.rb +5 -5
- data/test/mapping_test.rb +3 -3
- data/test/models/authenticatable_test.rb +3 -3
- data/test/models/confirmable_test.rb +32 -32
- data/test/models/database_authenticatable_test.rb +32 -27
- data/test/models/lockable_test.rb +57 -33
- data/test/models/recoverable_test.rb +34 -22
- data/test/models/rememberable_test.rb +29 -14
- data/test/models/serializable_test.rb +8 -8
- data/test/models/timeoutable_test.rb +1 -1
- data/test/models/trackable_test.rb +28 -0
- data/test/models/validatable_test.rb +13 -13
- data/test/omniauth/config_test.rb +4 -4
- data/test/omniauth/url_helpers_test.rb +3 -3
- data/test/orm/mongoid.rb +1 -1
- data/test/parameter_sanitizer_test.rb +1 -1
- data/test/rails_app/app/active_record/shim.rb +1 -1
- data/test/rails_app/app/active_record/user_on_engine.rb +7 -0
- data/test/rails_app/app/active_record/user_on_main_app.rb +7 -0
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +1 -1
- data/test/rails_app/app/controllers/admins_controller.rb +1 -1
- data/test/rails_app/app/controllers/application_controller.rb +5 -2
- data/test/rails_app/app/controllers/application_with_fake_engine.rb +30 -0
- data/test/rails_app/app/controllers/custom/registrations_controller.rb +21 -0
- data/test/rails_app/app/controllers/home_controller.rb +1 -1
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +1 -1
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +1 -1
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +4 -4
- data/test/rails_app/app/controllers/users_controller.rb +6 -6
- data/test/rails_app/app/mailers/users/mailer.rb +4 -4
- data/test/rails_app/app/mongoid/admin.rb +11 -11
- data/test/rails_app/app/mongoid/shim.rb +2 -2
- data/test/rails_app/app/mongoid/user.rb +19 -19
- data/test/rails_app/app/mongoid/user_on_engine.rb +39 -0
- data/test/rails_app/app/mongoid/user_on_main_app.rb +39 -0
- data/test/rails_app/app/views/admins/sessions/new.html.erb +1 -1
- data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -1
- data/test/rails_app/app/views/home/index.html.erb +1 -1
- data/test/rails_app/app/views/home/join.html.erb +1 -1
- data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -1
- data/test/rails_app/app/views/layouts/application.html.erb +1 -1
- data/test/rails_app/config/application.rb +2 -2
- data/test/rails_app/config/boot.rb +7 -1
- data/test/rails_app/config/environments/development.rb +0 -4
- data/test/rails_app/config/environments/production.rb +0 -4
- data/test/rails_app/config/initializers/devise.rb +7 -5
- data/test/rails_app/config/initializers/secret_token.rb +1 -1
- data/test/rails_app/config/routes.rb +60 -42
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +7 -7
- data/test/rails_app/db/schema.rb +21 -17
- data/test/rails_app/lib/shared_admin.rb +4 -4
- data/test/rails_app/lib/shared_user.rb +1 -1
- data/test/rails_app/lib/shared_user_without_omniauth.rb +13 -0
- data/test/routes_test.rb +72 -58
- data/test/support/action_controller/record_identifier.rb +10 -0
- data/test/support/assertions.rb +2 -3
- data/test/support/helpers.rb +4 -4
- data/test/support/integration.rb +14 -14
- data/test/support/mongoid.yml +6 -0
- data/test/test_helper.rb +2 -7
- data/test/test_helpers_test.rb +25 -35
- data/test/test_models.rb +12 -5
- metadata +53 -38
- data/gemfiles/Gemfile.rails-3.2.x.lock +0 -159
@@ -17,8 +17,8 @@ class OmniAuthRoutesTest < ActionController::TestCase
|
|
17
17
|
|
18
18
|
if with_param
|
19
19
|
# Default url params
|
20
|
-
assert_equal @controller.send(action, :user, provider, :
|
21
|
-
@controller.send("user_#{action}", provider, :
|
20
|
+
assert_equal @controller.send(action, :user, provider, param: 123),
|
21
|
+
@controller.send("user_#{action}", provider, param: 123)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -44,7 +44,7 @@ class OmniAuthRoutesTest < ActionController::TestCase
|
|
44
44
|
|
45
45
|
test 'should generate authorization path with params' do
|
46
46
|
assert_match "/users/auth/openid?openid_url=http%3A%2F%2Fyahoo.com",
|
47
|
-
@controller.omniauth_authorize_path(:user, :openid, :
|
47
|
+
@controller.omniauth_authorize_path(:user, :openid, openid_url: "http://yahoo.com")
|
48
48
|
end
|
49
49
|
|
50
50
|
test 'should not add a "?" if no param was sent' do
|
data/test/orm/mongoid.rb
CHANGED
@@ -27,7 +27,7 @@ if defined?(ActionController::StrongParameters)
|
|
27
27
|
end
|
28
28
|
|
29
29
|
test 'handles auth keys as a hash' do
|
30
|
-
swap Devise, :
|
30
|
+
swap Devise, authentication_keys: {email: true} do
|
31
31
|
sanitizer = sanitizer(user: { "email" => "jose", "password" => "invalid" })
|
32
32
|
assert_equal({ "email" => "jose", "password" => "invalid" }, sanitizer.sanitize(:sign_in))
|
33
33
|
end
|
@@ -1,2 +1,2 @@
|
|
1
1
|
module Shim
|
2
|
-
end
|
2
|
+
end
|
@@ -3,7 +3,10 @@
|
|
3
3
|
|
4
4
|
class ApplicationController < ActionController::Base
|
5
5
|
protect_from_forgery
|
6
|
-
before_filter :current_user, :
|
7
|
-
before_filter :authenticate_user!, :
|
6
|
+
before_filter :current_user, unless: :devise_controller?
|
7
|
+
before_filter :authenticate_user!, if: :devise_controller?
|
8
8
|
respond_to *Mime::SET.map(&:to_sym)
|
9
|
+
|
10
|
+
devise_group :commenter, contains: [:user, :admin]
|
9
11
|
end
|
12
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class ApplicationWithFakeEngine < ApplicationController
|
2
|
+
private
|
3
|
+
|
4
|
+
helper_method :fake_engine
|
5
|
+
def fake_engine
|
6
|
+
@fake_engine ||= FakeEngine.new
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class FakeEngine
|
11
|
+
def user_on_engine_confirmation_path
|
12
|
+
'/user_on_engine/confirmation'
|
13
|
+
end
|
14
|
+
|
15
|
+
def new_user_on_engine_session_path
|
16
|
+
'/user_on_engine/confirmation/new'
|
17
|
+
end
|
18
|
+
|
19
|
+
def new_user_on_engine_registration_path
|
20
|
+
'/user_on_engine/registration/new'
|
21
|
+
end
|
22
|
+
|
23
|
+
def new_user_on_engine_password_path
|
24
|
+
'/user_on_engine/password/new'
|
25
|
+
end
|
26
|
+
|
27
|
+
def new_user_on_engine_unlock_path
|
28
|
+
'/user_on_engine/unlock/new'
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Custom::RegistrationsController < Devise::RegistrationsController
|
2
|
+
def create
|
3
|
+
super do |resource|
|
4
|
+
@create_block_called = true
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def update
|
9
|
+
super do |resource|
|
10
|
+
@update_block_called = true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_block_called?
|
15
|
+
@create_block_called == true
|
16
|
+
end
|
17
|
+
|
18
|
+
def update_block_called?
|
19
|
+
@update_block_called == true
|
20
|
+
end
|
21
|
+
end
|
@@ -1,2 +1,2 @@
|
|
1
1
|
class Publisher::RegistrationsController < ApplicationController
|
2
|
-
end
|
2
|
+
end
|
@@ -1,2 +1,2 @@
|
|
1
1
|
class Publisher::SessionsController < ApplicationController
|
2
|
-
end
|
2
|
+
end
|
@@ -2,13 +2,13 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|
2
2
|
def facebook
|
3
3
|
data = env["omniauth.auth"]
|
4
4
|
session["devise.facebook_data"] = data["extra"]["user_hash"]
|
5
|
-
render :
|
5
|
+
render json: data
|
6
6
|
end
|
7
7
|
|
8
8
|
def sign_in_facebook
|
9
|
-
user = User.
|
9
|
+
user = User.to_adapter.find_first(email: 'user@test.com')
|
10
10
|
user.remember_me = true
|
11
11
|
sign_in user
|
12
|
-
render :
|
12
|
+
render text: ""
|
13
13
|
end
|
14
|
-
end
|
14
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class UsersController < ApplicationController
|
2
|
-
prepend_before_filter :current_user, :
|
3
|
-
before_filter :authenticate_user!, :
|
2
|
+
prepend_before_filter :current_user, only: :exhibit
|
3
|
+
before_filter :authenticate_user!, except: [:accept, :exhibit]
|
4
4
|
respond_to :html, :xml
|
5
5
|
|
6
6
|
def index
|
@@ -9,11 +9,11 @@ class UsersController < ApplicationController
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def edit_form
|
12
|
-
user_session['last_request_at'] = 31.minutes.ago.utc
|
12
|
+
user_session['last_request_at'] = params.fetch(:last_request_at, 31.minutes.ago.utc)
|
13
13
|
end
|
14
14
|
|
15
15
|
def update_form
|
16
|
-
render :
|
16
|
+
render text: 'Update'
|
17
17
|
end
|
18
18
|
|
19
19
|
def accept
|
@@ -21,11 +21,11 @@ class UsersController < ApplicationController
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def exhibit
|
24
|
-
render :
|
24
|
+
render text: current_user ? "User is authenticated" : "User is not authenticated"
|
25
25
|
end
|
26
26
|
|
27
27
|
def expire
|
28
28
|
user_session['last_request_at'] = 31.minutes.ago.utc
|
29
|
-
render :
|
29
|
+
render text: 'User will be expired on next request'
|
30
30
|
end
|
31
31
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class Users::Mailer < Devise::Mailer
|
2
|
-
default :
|
2
|
+
default from: 'custom@example.com'
|
3
3
|
end
|
4
4
|
|
5
5
|
class Users::ReplyToMailer < Devise::Mailer
|
6
|
-
default :
|
7
|
-
default :
|
6
|
+
default from: 'custom@example.com'
|
7
|
+
default reply_to: 'custom_reply_to@example.com'
|
8
8
|
end
|
9
9
|
|
10
10
|
class Users::FromProcMailer < Devise::Mailer
|
11
|
-
default :
|
11
|
+
default from: proc { 'custom@example.com' }
|
12
12
|
end
|
@@ -6,24 +6,24 @@ class Admin
|
|
6
6
|
include SharedAdmin
|
7
7
|
|
8
8
|
## Database authenticatable
|
9
|
-
field :email, :
|
10
|
-
field :encrypted_password, :
|
9
|
+
field :email, type: String
|
10
|
+
field :encrypted_password, type: String
|
11
11
|
|
12
12
|
## Recoverable
|
13
|
-
field :reset_password_token, :
|
14
|
-
field :reset_password_sent_at, :
|
13
|
+
field :reset_password_token, type: String
|
14
|
+
field :reset_password_sent_at, type: Time
|
15
15
|
|
16
16
|
## Rememberable
|
17
|
-
field :remember_created_at, :
|
17
|
+
field :remember_created_at, type: Time
|
18
18
|
|
19
19
|
## Confirmable
|
20
|
-
field :confirmation_token, :
|
21
|
-
field :confirmed_at, :
|
22
|
-
field :confirmation_sent_at, :
|
23
|
-
field :unconfirmed_email, :
|
20
|
+
field :confirmation_token, type: String
|
21
|
+
field :confirmed_at, type: Time
|
22
|
+
field :confirmation_sent_at, type: Time
|
23
|
+
field :unconfirmed_email, type: String # Only if using reconfirmable
|
24
24
|
|
25
25
|
## Lockable
|
26
|
-
field :locked_at, :
|
26
|
+
field :locked_at, type: Time
|
27
27
|
|
28
|
-
field :active, :
|
28
|
+
field :active, type: Boolean, default: false
|
29
29
|
end
|
@@ -3,7 +3,7 @@ module Shim
|
|
3
3
|
|
4
4
|
included do
|
5
5
|
include ::Mongoid::Timestamps
|
6
|
-
field :created_at, :
|
6
|
+
field :created_at, type: DateTime
|
7
7
|
end
|
8
8
|
|
9
9
|
module ClassMethods
|
@@ -12,7 +12,7 @@ module Shim
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def find_by_email(email)
|
15
|
-
find_by(:
|
15
|
+
find_by(email: email)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -5,35 +5,35 @@ class User
|
|
5
5
|
include Shim
|
6
6
|
include SharedUser
|
7
7
|
|
8
|
-
field :username, :
|
9
|
-
field :facebook_token, :
|
8
|
+
field :username, type: String
|
9
|
+
field :facebook_token, type: String
|
10
10
|
|
11
11
|
## Database authenticatable
|
12
|
-
field :email, :
|
13
|
-
field :encrypted_password, :
|
12
|
+
field :email, type: String, default: ""
|
13
|
+
field :encrypted_password, type: String, default: ""
|
14
14
|
|
15
15
|
## Recoverable
|
16
|
-
field :reset_password_token, :
|
17
|
-
field :reset_password_sent_at, :
|
16
|
+
field :reset_password_token, type: String
|
17
|
+
field :reset_password_sent_at, type: Time
|
18
18
|
|
19
19
|
## Rememberable
|
20
|
-
field :remember_created_at, :
|
20
|
+
field :remember_created_at, type: Time
|
21
21
|
|
22
22
|
## Trackable
|
23
|
-
field :sign_in_count, :
|
24
|
-
field :current_sign_in_at, :
|
25
|
-
field :last_sign_in_at, :
|
26
|
-
field :current_sign_in_ip, :
|
27
|
-
field :last_sign_in_ip, :
|
23
|
+
field :sign_in_count, type: Integer, default: 0
|
24
|
+
field :current_sign_in_at, type: Time
|
25
|
+
field :last_sign_in_at, type: Time
|
26
|
+
field :current_sign_in_ip, type: String
|
27
|
+
field :last_sign_in_ip, type: String
|
28
28
|
|
29
29
|
## Confirmable
|
30
|
-
field :confirmation_token, :
|
31
|
-
field :confirmed_at, :
|
32
|
-
field :confirmation_sent_at, :
|
33
|
-
# field :unconfirmed_email, :
|
30
|
+
field :confirmation_token, type: String
|
31
|
+
field :confirmed_at, type: Time
|
32
|
+
field :confirmation_sent_at, type: Time
|
33
|
+
# field :unconfirmed_email, type: String # Only if using reconfirmable
|
34
34
|
|
35
35
|
## Lockable
|
36
|
-
field :failed_attempts, :
|
37
|
-
field :unlock_token, :
|
38
|
-
field :locked_at, :
|
36
|
+
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
37
|
+
field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
38
|
+
field :locked_at, type: Time
|
39
39
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'shared_user_without_omniauth'
|
2
|
+
|
3
|
+
class UserOnEngine
|
4
|
+
include Mongoid::Document
|
5
|
+
include Shim
|
6
|
+
include SharedUserWithoutOmniauth
|
7
|
+
|
8
|
+
field :username, type: String
|
9
|
+
field :facebook_token, type: String
|
10
|
+
|
11
|
+
## Database authenticatable
|
12
|
+
field :email, type: String, default: ""
|
13
|
+
field :encrypted_password, type: String, default: ""
|
14
|
+
|
15
|
+
## Recoverable
|
16
|
+
field :reset_password_token, type: String
|
17
|
+
field :reset_password_sent_at, type: Time
|
18
|
+
|
19
|
+
## Rememberable
|
20
|
+
field :remember_created_at, type: Time
|
21
|
+
|
22
|
+
## Trackable
|
23
|
+
field :sign_in_count, type: Integer, default: 0
|
24
|
+
field :current_sign_in_at, type: Time
|
25
|
+
field :last_sign_in_at, type: Time
|
26
|
+
field :current_sign_in_ip, type: String
|
27
|
+
field :last_sign_in_ip, type: String
|
28
|
+
|
29
|
+
## Confirmable
|
30
|
+
field :confirmation_token, type: String
|
31
|
+
field :confirmed_at, type: Time
|
32
|
+
field :confirmation_sent_at, type: Time
|
33
|
+
# field :unconfirmed_email, type: String # Only if using reconfirmable
|
34
|
+
|
35
|
+
## Lockable
|
36
|
+
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
37
|
+
field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
38
|
+
field :locked_at, type: Time
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'shared_user_without_omniauth'
|
2
|
+
|
3
|
+
class UserOnMainApp
|
4
|
+
include Mongoid::Document
|
5
|
+
include Shim
|
6
|
+
include SharedUserWithoutOmniauth
|
7
|
+
|
8
|
+
field :username, type: String
|
9
|
+
field :facebook_token, type: String
|
10
|
+
|
11
|
+
## Database authenticatable
|
12
|
+
field :email, type: String, default: ""
|
13
|
+
field :encrypted_password, type: String, default: ""
|
14
|
+
|
15
|
+
## Recoverable
|
16
|
+
field :reset_password_token, type: String
|
17
|
+
field :reset_password_sent_at, type: Time
|
18
|
+
|
19
|
+
## Rememberable
|
20
|
+
field :remember_created_at, type: Time
|
21
|
+
|
22
|
+
## Trackable
|
23
|
+
field :sign_in_count, type: Integer, default: 0
|
24
|
+
field :current_sign_in_at, type: Time
|
25
|
+
field :last_sign_in_at, type: Time
|
26
|
+
field :current_sign_in_ip, type: String
|
27
|
+
field :last_sign_in_ip, type: String
|
28
|
+
|
29
|
+
## Confirmable
|
30
|
+
field :confirmation_token, type: String
|
31
|
+
field :confirmed_at, type: Time
|
32
|
+
field :confirmation_sent_at, type: Time
|
33
|
+
# field :unconfirmed_email, type: String # Only if using reconfirmable
|
34
|
+
|
35
|
+
## Lockable
|
36
|
+
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
37
|
+
field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
38
|
+
field :locked_at, type: Time
|
39
|
+
end
|
@@ -1,2 +1,2 @@
|
|
1
1
|
Welcome to "sessions/new" view!
|
2
|
-
<%= render :
|
2
|
+
<%= render file: "devise/sessions/new" %>
|
@@ -1 +1 @@
|
|
1
|
-
Admin dashboard
|
1
|
+
Admin dashboard
|
@@ -1 +1 @@
|
|
1
|
-
Home!
|
1
|
+
Home!
|
@@ -1 +1 @@
|
|
1
|
-
Join
|
1
|
+
Join
|
@@ -1 +1 @@
|
|
1
|
-
User dashboard
|
1
|
+
User dashboard
|
@@ -23,14 +23,14 @@ module RailsApp
|
|
23
23
|
# config.generators do |g|
|
24
24
|
# g.orm :active_record
|
25
25
|
# g.template_engine :erb
|
26
|
-
# g.test_framework :test_unit, :
|
26
|
+
# g.test_framework :test_unit, fixture: true
|
27
27
|
# end
|
28
28
|
|
29
29
|
# Configure sensitive parameters which will be filtered from the log file.
|
30
30
|
config.filter_parameters << :password
|
31
31
|
config.assets.enabled = false
|
32
32
|
|
33
|
-
config.action_mailer.default_url_options = { :
|
33
|
+
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
|
34
34
|
|
35
35
|
# This was used to break devise in some situations
|
36
36
|
config.to_prepare do
|
@@ -2,7 +2,13 @@ unless defined?(DEVISE_ORM)
|
|
2
2
|
DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym
|
3
3
|
end
|
4
4
|
|
5
|
+
module Devise
|
6
|
+
# Detection for minor differences between Rails 3.2 and 4 in tests.
|
7
|
+
def self.rails4?
|
8
|
+
Rails.version.start_with? '4'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
5
12
|
# Set up gems listed in the Gemfile.
|
6
13
|
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
|
7
|
-
|
8
14
|
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
@@ -22,10 +22,6 @@ RailsApp::Application.configure do
|
|
22
22
|
# Only use best-standards-support built into browsers.
|
23
23
|
config.action_dispatch.best_standards_support = :builtin
|
24
24
|
|
25
|
-
# Log the query plan for queries taking more than this (works
|
26
|
-
# with SQLite, MySQL, and PostgreSQL).
|
27
|
-
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
28
|
-
|
29
25
|
# Raise an error on page load if there are pending migrations
|
30
26
|
config.active_record.migration_error = :page_load
|
31
27
|
|
@@ -72,10 +72,6 @@ RailsApp::Application.configure do
|
|
72
72
|
# Send deprecation notices to registered listeners.
|
73
73
|
config.active_support.deprecation = :notify
|
74
74
|
|
75
|
-
# Log the query plan for queries taking more than this (works
|
76
|
-
# with SQLite, MySQL, and PostgreSQL).
|
77
|
-
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
78
|
-
|
79
75
|
# Disable automatic flushing of the log to improve performance.
|
80
76
|
# config.autoflush_log = false
|
81
77
|
|
@@ -12,6 +12,8 @@ Devise.setup do |config|
|
|
12
12
|
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
|
13
13
|
config.mailer_sender = "please-change-me@config-initializers-devise.com"
|
14
14
|
|
15
|
+
|
16
|
+
config.parent_controller = "ApplicationWithFakeEngine"
|
15
17
|
# Configure the class responsible to send e-mails.
|
16
18
|
# config.mailer = "Devise::Mailer"
|
17
19
|
|
@@ -66,8 +68,8 @@ Devise.setup do |config|
|
|
66
68
|
config.stretches = Rails.env.test? ? 1 : 10
|
67
69
|
|
68
70
|
# ==> Configuration for :confirmable
|
69
|
-
# The time you want to give your user to confirm
|
70
|
-
#
|
71
|
+
# The time you want to give your user to confirm their account. During this time
|
72
|
+
# they will be able to access your application without confirming. Default is nil.
|
71
73
|
# When allow_unconfirmed_access_for is zero, the user won't be able to sign in without confirming.
|
72
74
|
# You can use this to let your user access some features of your application
|
73
75
|
# without confirming the account, but blocking it after a certain period
|
@@ -166,9 +168,9 @@ Devise.setup do |config|
|
|
166
168
|
# config.sign_out_via = :get
|
167
169
|
|
168
170
|
# ==> OmniAuth
|
169
|
-
config.omniauth :facebook, 'APP_ID', 'APP_SECRET', :
|
171
|
+
config.omniauth :facebook, 'APP_ID', 'APP_SECRET', scope: 'email,offline_access'
|
170
172
|
config.omniauth :openid
|
171
|
-
config.omniauth :openid, :
|
173
|
+
config.omniauth :openid, name: 'google', identifier: 'https://www.google.com/accounts/o8/id'
|
172
174
|
|
173
175
|
# ==> Warden configuration
|
174
176
|
# If you want to use other strategies, that are not supported by Devise, or
|
@@ -176,6 +178,6 @@ Devise.setup do |config|
|
|
176
178
|
#
|
177
179
|
# config.warden do |manager|
|
178
180
|
# manager.failure_app = AnotherApp
|
179
|
-
# manager.default_strategies(:
|
181
|
+
# manager.default_strategies(scope: :user).unshift :some_external_strategy
|
180
182
|
# end
|
181
183
|
end
|
@@ -4,5 +4,5 @@ if Devise.rails4?
|
|
4
4
|
config.secret_key_base = 'd588e99efff13a86461fd6ab82327823ad2f8feb5dc217ce652cdd9f0dfc5eb4b5a62a92d24d2574d7d51dfb1ea8dd453ea54e00cf672159a13104a135422a10'
|
5
5
|
else
|
6
6
|
config.secret_token = 'ea942c41850d502f2c8283e26bdc57829f471bb18224ddff0a192c4f32cdf6cb5aa0d82b3a7a7adbeb640c4b06f3aa1cd5f098162d8240f669b39d6b49680571'
|
7
|
-
config.session_store :cookie_store, :
|
7
|
+
config.session_store :cookie_store, key: "_my_app"
|
8
8
|
end
|