devise 3.2.2 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of devise might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/CHANGELOG.md +242 -978
- data/MIT-LICENSE +1 -1
- data/README.md +371 -100
- data/app/controllers/devise/confirmations_controller.rb +11 -5
- data/app/controllers/devise/omniauth_callbacks_controller.rb +12 -6
- data/app/controllers/devise/passwords_controller.rb +21 -8
- data/app/controllers/devise/registrations_controller.rb +59 -26
- data/app/controllers/devise/sessions_controller.rb +47 -17
- data/app/controllers/devise/unlocks_controller.rb +9 -4
- data/app/controllers/devise_controller.rb +67 -31
- data/app/helpers/devise_helper.rb +12 -19
- data/app/mailers/devise/mailer.rb +10 -0
- data/app/views/devise/confirmations/new.html.erb +9 -5
- data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
- data/app/views/devise/mailer/email_changed.html.erb +7 -0
- data/app/views/devise/mailer/password_change.html.erb +3 -0
- 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 +16 -7
- data/app/views/devise/passwords/new.html.erb +9 -5
- data/app/views/devise/registrations/edit.html.erb +29 -15
- data/app/views/devise/registrations/new.html.erb +20 -9
- data/app/views/devise/sessions/new.html.erb +19 -10
- data/app/views/devise/shared/_error_messages.html.erb +15 -0
- data/app/views/devise/shared/{_links.erb → _links.html.erb} +9 -9
- data/app/views/devise/unlocks/new.html.erb +9 -5
- data/config/locales/en.yml +23 -17
- data/lib/devise/controllers/helpers.rb +112 -32
- data/lib/devise/controllers/rememberable.rb +15 -6
- data/lib/devise/controllers/scoped_views.rb +3 -1
- data/lib/devise/controllers/sign_in_out.rb +42 -26
- data/lib/devise/controllers/store_location.rb +31 -5
- data/lib/devise/controllers/url_helpers.rb +9 -7
- data/lib/devise/delegator.rb +2 -0
- data/lib/devise/encryptor.rb +24 -0
- data/lib/devise/failure_app.rb +125 -39
- data/lib/devise/hooks/activatable.rb +7 -6
- data/lib/devise/hooks/csrf_cleaner.rb +5 -1
- data/lib/devise/hooks/forgetable.rb +2 -0
- data/lib/devise/hooks/lockable.rb +7 -2
- data/lib/devise/hooks/proxy.rb +4 -2
- data/lib/devise/hooks/rememberable.rb +4 -2
- data/lib/devise/hooks/timeoutable.rb +16 -9
- data/lib/devise/hooks/trackable.rb +3 -1
- data/lib/devise/mailers/helpers.rb +15 -12
- data/lib/devise/mapping.rb +8 -2
- data/lib/devise/models/authenticatable.rb +82 -56
- data/lib/devise/models/confirmable.rb +125 -42
- data/lib/devise/models/database_authenticatable.rb +110 -32
- data/lib/devise/models/lockable.rb +30 -17
- data/lib/devise/models/omniauthable.rb +3 -1
- data/lib/devise/models/recoverable.rb +62 -26
- data/lib/devise/models/registerable.rb +4 -0
- data/lib/devise/models/rememberable.rb +62 -33
- data/lib/devise/models/timeoutable.rb +4 -8
- data/lib/devise/models/trackable.rb +20 -4
- data/lib/devise/models/validatable.rb +16 -9
- data/lib/devise/models.rb +3 -1
- data/lib/devise/modules.rb +12 -10
- data/lib/devise/omniauth/config.rb +2 -0
- data/lib/devise/omniauth/url_helpers.rb +14 -5
- data/lib/devise/omniauth.rb +2 -0
- data/lib/devise/orm/active_record.rb +5 -1
- data/lib/devise/orm/mongoid.rb +6 -2
- data/lib/devise/parameter_filter.rb +4 -0
- data/lib/devise/parameter_sanitizer.rb +139 -65
- data/lib/devise/rails/routes.rb +147 -116
- data/lib/devise/rails/warden_compat.rb +3 -10
- data/lib/devise/rails.rb +10 -13
- data/lib/devise/secret_key_finder.rb +27 -0
- data/lib/devise/strategies/authenticatable.rb +20 -9
- data/lib/devise/strategies/base.rb +3 -1
- data/lib/devise/strategies/database_authenticatable.rb +14 -6
- data/lib/devise/strategies/rememberable.rb +15 -3
- data/lib/devise/test/controller_helpers.rb +165 -0
- data/lib/devise/test/integration_helpers.rb +63 -0
- data/lib/devise/test_helpers.rb +7 -124
- data/lib/devise/time_inflector.rb +4 -2
- data/lib/devise/token_generator.rb +3 -41
- data/lib/devise/version.rb +3 -1
- data/lib/devise.rb +111 -84
- data/lib/generators/active_record/devise_generator.rb +49 -12
- data/lib/generators/active_record/templates/migration.rb +9 -7
- data/lib/generators/active_record/templates/migration_existing.rb +9 -7
- data/lib/generators/devise/controllers_generator.rb +46 -0
- data/lib/generators/devise/devise_generator.rb +7 -5
- data/lib/generators/devise/install_generator.rb +21 -0
- data/lib/generators/devise/orm_helpers.rb +10 -21
- data/lib/generators/devise/views_generator.rb +49 -28
- data/lib/generators/mongoid/devise_generator.rb +21 -19
- data/lib/generators/templates/README +5 -12
- data/lib/generators/templates/controllers/README +14 -0
- data/lib/generators/templates/controllers/confirmations_controller.rb +30 -0
- data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +30 -0
- data/lib/generators/templates/controllers/passwords_controller.rb +34 -0
- data/lib/generators/templates/controllers/registrations_controller.rb +62 -0
- data/lib/generators/templates/controllers/sessions_controller.rb +27 -0
- data/lib/generators/templates/controllers/unlocks_controller.rb +30 -0
- data/lib/generators/templates/devise.rb +81 -36
- data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
- data/lib/generators/templates/markerb/email_changed.markerb +7 -0
- data/lib/generators/templates/markerb/password_change.markerb +3 -0
- 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 +6 -2
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +9 -4
- data/lib/generators/templates/simple_form_for/passwords/new.html.erb +5 -2
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +14 -6
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +12 -4
- data/lib/generators/templates/simple_form_for/sessions/new.html.erb +11 -6
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +5 -2
- metadata +52 -280
- data/.gitignore +0 -10
- data/.travis.yml +0 -20
- data/.yardopts +0 -9
- data/CONTRIBUTING.md +0 -14
- data/Gemfile +0 -31
- data/Gemfile.lock +0 -160
- data/Rakefile +0 -35
- data/devise.gemspec +0 -27
- data/devise.png +0 -0
- data/gemfiles/Gemfile.rails-3.2.x +0 -31
- data/gemfiles/Gemfile.rails-3.2.x.lock +0 -159
- data/test/controllers/custom_strategy_test.rb +0 -62
- data/test/controllers/helpers_test.rb +0 -276
- data/test/controllers/internal_helpers_test.rb +0 -120
- data/test/controllers/passwords_controller_test.rb +0 -31
- data/test/controllers/sessions_controller_test.rb +0 -99
- data/test/controllers/url_helpers_test.rb +0 -59
- data/test/delegator_test.rb +0 -19
- data/test/devise_test.rb +0 -94
- data/test/failure_app_test.rb +0 -232
- data/test/generators/active_record_generator_test.rb +0 -103
- data/test/generators/devise_generator_test.rb +0 -39
- data/test/generators/install_generator_test.rb +0 -13
- data/test/generators/mongoid_generator_test.rb +0 -23
- data/test/generators/views_generator_test.rb +0 -67
- data/test/helpers/devise_helper_test.rb +0 -51
- data/test/integration/authenticatable_test.rb +0 -713
- data/test/integration/confirmable_test.rb +0 -284
- data/test/integration/database_authenticatable_test.rb +0 -84
- data/test/integration/http_authenticatable_test.rb +0 -105
- data/test/integration/lockable_test.rb +0 -239
- data/test/integration/omniauthable_test.rb +0 -133
- data/test/integration/recoverable_test.rb +0 -334
- data/test/integration/registerable_test.rb +0 -349
- data/test/integration/rememberable_test.rb +0 -167
- data/test/integration/timeoutable_test.rb +0 -183
- data/test/integration/trackable_test.rb +0 -92
- data/test/mailers/confirmation_instructions_test.rb +0 -115
- data/test/mailers/reset_password_instructions_test.rb +0 -96
- data/test/mailers/unlock_instructions_test.rb +0 -91
- data/test/mapping_test.rb +0 -127
- data/test/models/authenticatable_test.rb +0 -13
- data/test/models/confirmable_test.rb +0 -454
- data/test/models/database_authenticatable_test.rb +0 -249
- data/test/models/lockable_test.rb +0 -298
- data/test/models/omniauthable_test.rb +0 -7
- data/test/models/recoverable_test.rb +0 -184
- data/test/models/registerable_test.rb +0 -7
- data/test/models/rememberable_test.rb +0 -183
- data/test/models/serializable_test.rb +0 -49
- data/test/models/timeoutable_test.rb +0 -51
- data/test/models/trackable_test.rb +0 -13
- data/test/models/validatable_test.rb +0 -127
- data/test/models_test.rb +0 -144
- data/test/omniauth/config_test.rb +0 -57
- data/test/omniauth/url_helpers_test.rb +0 -54
- data/test/orm/active_record.rb +0 -10
- data/test/orm/mongoid.rb +0 -13
- data/test/parameter_sanitizer_test.rb +0 -81
- data/test/rails_app/Rakefile +0 -6
- data/test/rails_app/app/active_record/admin.rb +0 -6
- data/test/rails_app/app/active_record/shim.rb +0 -2
- data/test/rails_app/app/active_record/user.rb +0 -6
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +0 -6
- data/test/rails_app/app/controllers/admins_controller.rb +0 -11
- data/test/rails_app/app/controllers/application_controller.rb +0 -9
- data/test/rails_app/app/controllers/home_controller.rb +0 -25
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +0 -2
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +0 -2
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +0 -14
- data/test/rails_app/app/controllers/users_controller.rb +0 -31
- data/test/rails_app/app/helpers/application_helper.rb +0 -3
- data/test/rails_app/app/mailers/users/mailer.rb +0 -12
- data/test/rails_app/app/mongoid/admin.rb +0 -29
- data/test/rails_app/app/mongoid/shim.rb +0 -23
- data/test/rails_app/app/mongoid/user.rb +0 -39
- data/test/rails_app/app/views/admins/index.html.erb +0 -1
- data/test/rails_app/app/views/admins/sessions/new.html.erb +0 -2
- data/test/rails_app/app/views/home/admin_dashboard.html.erb +0 -1
- data/test/rails_app/app/views/home/index.html.erb +0 -1
- data/test/rails_app/app/views/home/join.html.erb +0 -1
- data/test/rails_app/app/views/home/private.html.erb +0 -1
- data/test/rails_app/app/views/home/user_dashboard.html.erb +0 -1
- data/test/rails_app/app/views/layouts/application.html.erb +0 -24
- data/test/rails_app/app/views/users/edit_form.html.erb +0 -1
- data/test/rails_app/app/views/users/index.html.erb +0 -1
- data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +0 -1
- data/test/rails_app/app/views/users/sessions/new.html.erb +0 -1
- data/test/rails_app/bin/bundle +0 -3
- data/test/rails_app/bin/rails +0 -4
- data/test/rails_app/bin/rake +0 -4
- data/test/rails_app/config/application.rb +0 -40
- data/test/rails_app/config/boot.rb +0 -14
- data/test/rails_app/config/database.yml +0 -18
- data/test/rails_app/config/environment.rb +0 -5
- data/test/rails_app/config/environments/development.rb +0 -30
- data/test/rails_app/config/environments/production.rb +0 -80
- data/test/rails_app/config/environments/test.rb +0 -36
- data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -7
- data/test/rails_app/config/initializers/devise.rb +0 -181
- data/test/rails_app/config/initializers/inflections.rb +0 -2
- data/test/rails_app/config/initializers/secret_token.rb +0 -8
- data/test/rails_app/config/initializers/session_store.rb +0 -1
- data/test/rails_app/config/routes.rb +0 -104
- data/test/rails_app/config.ru +0 -4
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -71
- data/test/rails_app/db/schema.rb +0 -55
- data/test/rails_app/lib/shared_admin.rb +0 -17
- data/test/rails_app/lib/shared_user.rb +0 -29
- data/test/rails_app/public/404.html +0 -26
- data/test/rails_app/public/422.html +0 -26
- data/test/rails_app/public/500.html +0 -26
- data/test/rails_app/public/favicon.ico +0 -0
- data/test/routes_test.rb +0 -250
- data/test/support/assertions.rb +0 -40
- data/test/support/helpers.rb +0 -70
- data/test/support/integration.rb +0 -92
- data/test/support/locale/en.yml +0 -8
- data/test/support/webrat/integrations/rails.rb +0 -24
- data/test/test_helper.rb +0 -27
- data/test/test_helpers_test.rb +0 -173
- data/test/test_models.rb +0 -33
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails/generators/named_base'
|
2
4
|
|
3
5
|
module Devise
|
@@ -8,17 +10,17 @@ module Devise
|
|
8
10
|
namespace "devise"
|
9
11
|
source_root File.expand_path("../templates", __FILE__)
|
10
12
|
|
11
|
-
desc "Generates a model with the given NAME (if one does not exist) with devise "
|
13
|
+
desc "Generates a model with the given NAME (if one does not exist) with devise " \
|
12
14
|
"configuration plus a migration file and devise routes."
|
13
15
|
|
14
16
|
hook_for :orm
|
15
17
|
|
16
|
-
class_option :routes, :
|
18
|
+
class_option :routes, desc: "Generate routes", type: :boolean, default: true
|
17
19
|
|
18
20
|
def add_devise_routes
|
19
|
-
devise_route = "devise_for :#{plural_name}"
|
20
|
-
devise_route << %Q(, :
|
21
|
-
devise_route << %Q(, :
|
21
|
+
devise_route = "devise_for :#{plural_name}".dup
|
22
|
+
devise_route << %Q(, class_name: "#{class_name}") if class_name.include?("::")
|
23
|
+
devise_route << %Q(, skip: :all) unless options.routes?
|
22
24
|
route devise_route
|
23
25
|
end
|
24
26
|
end
|
@@ -1,8 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails/generators/base'
|
2
4
|
require 'securerandom'
|
3
5
|
|
4
6
|
module Devise
|
5
7
|
module Generators
|
8
|
+
MissingORMError = Class.new(Thor::Error)
|
9
|
+
|
6
10
|
class InstallGenerator < Rails::Generators::Base
|
7
11
|
source_root File.expand_path("../../templates", __FILE__)
|
8
12
|
|
@@ -10,6 +14,19 @@ module Devise
|
|
10
14
|
class_option :orm
|
11
15
|
|
12
16
|
def copy_initializer
|
17
|
+
unless options[:orm]
|
18
|
+
raise MissingORMError, <<-ERROR.strip_heredoc
|
19
|
+
An ORM must be set to install Devise in your application.
|
20
|
+
|
21
|
+
Be sure to have an ORM like Active Record or Mongoid loaded in your
|
22
|
+
app or configure your own at `config/application.rb`.
|
23
|
+
|
24
|
+
config.generators do |g|
|
25
|
+
g.orm :your_orm_gem
|
26
|
+
end
|
27
|
+
ERROR
|
28
|
+
end
|
29
|
+
|
13
30
|
template "devise.rb", "config/initializers/devise.rb"
|
14
31
|
end
|
15
32
|
|
@@ -20,6 +37,10 @@ module Devise
|
|
20
37
|
def show_readme
|
21
38
|
readme "README" if behavior == :invoke
|
22
39
|
end
|
40
|
+
|
41
|
+
def rails_4?
|
42
|
+
Rails::VERSION::MAJOR == 4
|
43
|
+
end
|
23
44
|
end
|
24
45
|
end
|
25
46
|
end
|
@@ -1,38 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Devise
|
2
4
|
module Generators
|
3
5
|
module OrmHelpers
|
4
6
|
def model_contents
|
5
7
|
buffer = <<-CONTENT
|
6
8
|
# Include default devise modules. Others available are:
|
7
|
-
# :confirmable, :lockable, :timeoutable and :omniauthable
|
9
|
+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
8
10
|
devise :database_authenticatable, :registerable,
|
9
|
-
:recoverable, :rememberable, :
|
10
|
-
|
11
|
-
CONTENT
|
12
|
-
buffer += <<-CONTENT if needs_attr_accessible?
|
13
|
-
# Setup accessible (or protected) attributes for your model
|
14
|
-
attr_accessible :email, :password, :password_confirmation, :remember_me
|
11
|
+
:recoverable, :rememberable, :validatable
|
15
12
|
|
16
13
|
CONTENT
|
17
14
|
buffer
|
18
15
|
end
|
19
16
|
|
20
|
-
def needs_attr_accessible?
|
21
|
-
rails_3? && !strong_parameters_enabled?
|
22
|
-
end
|
23
|
-
|
24
|
-
def rails_3?
|
25
|
-
Rails::VERSION::MAJOR == 3
|
26
|
-
end
|
27
|
-
|
28
|
-
def strong_parameters_enabled?
|
29
|
-
defined?(ActionController::StrongParameters)
|
30
|
-
end
|
31
|
-
|
32
17
|
private
|
33
18
|
|
34
19
|
def model_exists?
|
35
|
-
File.
|
20
|
+
File.exist?(File.join(destination_root, model_path))
|
36
21
|
end
|
37
22
|
|
38
23
|
def migration_exists?(table_name)
|
@@ -40,7 +25,11 @@ CONTENT
|
|
40
25
|
end
|
41
26
|
|
42
27
|
def migration_path
|
43
|
-
|
28
|
+
if Rails.version >= '5.0.3'
|
29
|
+
db_migrate_path
|
30
|
+
else
|
31
|
+
@migration_path ||= File.join("db", "migrate")
|
32
|
+
end
|
44
33
|
end
|
45
34
|
|
46
35
|
def model_path
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails/generators/base'
|
2
4
|
|
3
5
|
module Devise
|
@@ -9,30 +11,30 @@ module Devise
|
|
9
11
|
extend ActiveSupport::Concern
|
10
12
|
|
11
13
|
included do
|
12
|
-
argument :scope, :
|
13
|
-
:
|
14
|
+
argument :scope, required: false, default: nil,
|
15
|
+
desc: "The scope to copy views to"
|
14
16
|
|
15
17
|
# Le sigh, ensure Thor won't handle opts as args
|
16
18
|
# It should be fixed in future Rails releases
|
17
|
-
class_option :form_builder, :
|
19
|
+
class_option :form_builder, aliases: "-b"
|
18
20
|
class_option :markerb
|
21
|
+
class_option :views, aliases: "-v", type: :array, desc: "Select specific view directories to generate (confirmations, passwords, registrations, sessions, unlocks, mailer)"
|
19
22
|
|
20
23
|
public_task :copy_views
|
21
24
|
end
|
22
25
|
|
23
|
-
# TODO: Add this to Rails itself
|
24
|
-
module ClassMethods
|
25
|
-
def hide!
|
26
|
-
Rails::Generators.hide_namespace self.namespace
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
26
|
def copy_views
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
if options[:views]
|
28
|
+
options[:views].each do |directory|
|
29
|
+
view_directory directory.to_sym
|
30
|
+
end
|
31
|
+
else
|
32
|
+
view_directory :confirmations
|
33
|
+
view_directory :passwords
|
34
|
+
view_directory :registrations
|
35
|
+
view_directory :sessions
|
36
|
+
view_directory :unlocks
|
37
|
+
end
|
36
38
|
end
|
37
39
|
|
38
40
|
protected
|
@@ -40,7 +42,7 @@ module Devise
|
|
40
42
|
def view_directory(name, _target_path = nil)
|
41
43
|
directory name.to_s, _target_path || "#{target_path}/#{name}" do |content|
|
42
44
|
if scope
|
43
|
-
content.gsub "devise/shared/links", "#{
|
45
|
+
content.gsub "devise/shared/links", "#{plural_scope}/shared/links"
|
44
46
|
else
|
45
47
|
content
|
46
48
|
end
|
@@ -48,7 +50,11 @@ module Devise
|
|
48
50
|
end
|
49
51
|
|
50
52
|
def target_path
|
51
|
-
@target_path ||= "app/views/#{
|
53
|
+
@target_path ||= "app/views/#{plural_scope || :devise}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def plural_scope
|
57
|
+
@plural_scope ||= scope.presence && scope.underscore.pluralize
|
52
58
|
end
|
53
59
|
end
|
54
60
|
|
@@ -76,6 +82,13 @@ module Devise
|
|
76
82
|
source_root File.expand_path("../../templates/simple_form_for", __FILE__)
|
77
83
|
desc "Copies simple form enabled views to your application."
|
78
84
|
hide!
|
85
|
+
|
86
|
+
def copy_views
|
87
|
+
if options[:views]
|
88
|
+
options[:views].delete('mailer')
|
89
|
+
end
|
90
|
+
super
|
91
|
+
end
|
79
92
|
end
|
80
93
|
|
81
94
|
class ErbGenerator < Rails::Generators::Base #:nodoc:
|
@@ -85,7 +98,9 @@ module Devise
|
|
85
98
|
hide!
|
86
99
|
|
87
100
|
def copy_views
|
88
|
-
|
101
|
+
if !options[:views] || options[:views].include?('mailer')
|
102
|
+
view_directory :mailer
|
103
|
+
end
|
89
104
|
end
|
90
105
|
end
|
91
106
|
|
@@ -96,29 +111,35 @@ module Devise
|
|
96
111
|
hide!
|
97
112
|
|
98
113
|
def copy_views
|
99
|
-
|
114
|
+
if !options[:views] || options[:views].include?('mailer')
|
115
|
+
view_directory :markerb, target_path
|
116
|
+
end
|
100
117
|
end
|
101
118
|
|
102
119
|
def target_path
|
103
|
-
"app/views/#{
|
120
|
+
"app/views/#{plural_scope || :devise}/mailer"
|
104
121
|
end
|
105
122
|
end
|
106
123
|
|
107
124
|
class ViewsGenerator < Rails::Generators::Base
|
108
125
|
desc "Copies Devise views to your application."
|
109
126
|
|
110
|
-
argument :scope, :
|
111
|
-
:
|
127
|
+
argument :scope, required: false, default: nil,
|
128
|
+
desc: "The scope to copy views to"
|
112
129
|
|
113
130
|
invoke SharedViewsGenerator
|
114
131
|
|
115
|
-
hook_for :form_builder, :
|
116
|
-
:
|
117
|
-
:
|
132
|
+
hook_for :form_builder, aliases: "-b",
|
133
|
+
desc: "Form builder to be used",
|
134
|
+
default: defined?(SimpleForm) ? "simple_form_for" : "form_for"
|
135
|
+
|
136
|
+
hook_for :markerb, desc: "Generate markerb instead of erb mail views",
|
137
|
+
default: defined?(Markerb),
|
138
|
+
type: :boolean
|
118
139
|
|
119
|
-
hook_for :
|
120
|
-
:
|
121
|
-
:
|
140
|
+
hook_for :erb, desc: "Generate erb mail views",
|
141
|
+
default: !defined?(Markerb),
|
142
|
+
type: :boolean
|
122
143
|
end
|
123
144
|
end
|
124
145
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails/generators/named_base'
|
2
4
|
require 'generators/devise/orm_helpers'
|
3
5
|
|
@@ -11,43 +13,43 @@ module Mongoid
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def inject_field_types
|
14
|
-
inject_into_file model_path, migration_data, :
|
16
|
+
inject_into_file model_path, migration_data, after: "include Mongoid::Document\n" if model_exists?
|
15
17
|
end
|
16
18
|
|
17
19
|
def inject_devise_content
|
18
|
-
inject_into_file model_path, model_contents, :
|
20
|
+
inject_into_file model_path, model_contents, after: "include Mongoid::Document\n" if model_exists?
|
19
21
|
end
|
20
22
|
|
21
23
|
def migration_data
|
22
24
|
<<RUBY
|
23
25
|
## Database authenticatable
|
24
|
-
field :email, :
|
25
|
-
field :encrypted_password, :
|
26
|
+
field :email, type: String, default: ""
|
27
|
+
field :encrypted_password, type: String, default: ""
|
26
28
|
|
27
29
|
## Recoverable
|
28
|
-
field :reset_password_token, :
|
29
|
-
field :reset_password_sent_at, :
|
30
|
+
field :reset_password_token, type: String
|
31
|
+
field :reset_password_sent_at, type: Time
|
30
32
|
|
31
33
|
## Rememberable
|
32
|
-
field :remember_created_at, :
|
34
|
+
field :remember_created_at, type: Time
|
33
35
|
|
34
36
|
## Trackable
|
35
|
-
field :sign_in_count, :
|
36
|
-
field :current_sign_in_at, :
|
37
|
-
field :last_sign_in_at, :
|
38
|
-
field :current_sign_in_ip, :
|
39
|
-
field :last_sign_in_ip, :
|
37
|
+
# field :sign_in_count, type: Integer, default: 0
|
38
|
+
# field :current_sign_in_at, type: Time
|
39
|
+
# field :last_sign_in_at, type: Time
|
40
|
+
# field :current_sign_in_ip, type: String
|
41
|
+
# field :last_sign_in_ip, type: String
|
40
42
|
|
41
43
|
## Confirmable
|
42
|
-
# field :confirmation_token, :
|
43
|
-
# field :confirmed_at, :
|
44
|
-
# field :confirmation_sent_at, :
|
45
|
-
# field :unconfirmed_email, :
|
44
|
+
# field :confirmation_token, type: String
|
45
|
+
# field :confirmed_at, type: Time
|
46
|
+
# field :confirmation_sent_at, type: Time
|
47
|
+
# field :unconfirmed_email, type: String # Only if using reconfirmable
|
46
48
|
|
47
49
|
## Lockable
|
48
|
-
# field :failed_attempts, :
|
49
|
-
# field :unlock_token, :
|
50
|
-
# field :locked_at, :
|
50
|
+
# field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
51
|
+
# field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
52
|
+
# field :locked_at, type: Time
|
51
53
|
RUBY
|
52
54
|
end
|
53
55
|
end
|
@@ -2,18 +2,18 @@
|
|
2
2
|
|
3
3
|
Some setup you must do manually if you haven't yet:
|
4
4
|
|
5
|
-
1. Ensure you have defined default url options in your environments files. Here
|
6
|
-
is an example of default_url_options appropriate for a development environment
|
5
|
+
1. Ensure you have defined default url options in your environments files. Here
|
6
|
+
is an example of default_url_options appropriate for a development environment
|
7
7
|
in config/environments/development.rb:
|
8
8
|
|
9
|
-
config.action_mailer.default_url_options = { :
|
9
|
+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
10
10
|
|
11
11
|
In production, :host should be set to the actual host of your application.
|
12
12
|
|
13
13
|
2. Ensure you have defined root_url to *something* in your config/routes.rb.
|
14
14
|
For example:
|
15
15
|
|
16
|
-
root :
|
16
|
+
root to: "home#index"
|
17
17
|
|
18
18
|
3. Ensure you have flash messages in app/views/layouts/application.html.erb.
|
19
19
|
For example:
|
@@ -21,14 +21,7 @@ Some setup you must do manually if you haven't yet:
|
|
21
21
|
<p class="notice"><%= notice %></p>
|
22
22
|
<p class="alert"><%= alert %></p>
|
23
23
|
|
24
|
-
4.
|
25
|
-
|
26
|
-
config.assets.initialize_on_precompile = false
|
27
|
-
|
28
|
-
On config/application.rb forcing your application to not access the DB
|
29
|
-
or load models when precompiling your assets.
|
30
|
-
|
31
|
-
5. You can copy Devise views (for customization) to your app by running:
|
24
|
+
4. You can copy Devise views (for customization) to your app by running:
|
32
25
|
|
33
26
|
rails g devise:views
|
34
27
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
===============================================================================
|
2
|
+
|
3
|
+
Some setup you must do manually if you haven't yet:
|
4
|
+
|
5
|
+
Ensure you have overridden routes for generated controllers in your routes.rb.
|
6
|
+
For example:
|
7
|
+
|
8
|
+
Rails.application.routes.draw do
|
9
|
+
devise_for :users, controllers: {
|
10
|
+
sessions: 'users/sessions'
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
===============================================================================
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class <%= @scope_prefix %>ConfirmationsController < Devise::ConfirmationsController
|
4
|
+
# GET /resource/confirmation/new
|
5
|
+
# def new
|
6
|
+
# super
|
7
|
+
# end
|
8
|
+
|
9
|
+
# POST /resource/confirmation
|
10
|
+
# def create
|
11
|
+
# super
|
12
|
+
# end
|
13
|
+
|
14
|
+
# GET /resource/confirmation?confirmation_token=abcdef
|
15
|
+
# def show
|
16
|
+
# super
|
17
|
+
# end
|
18
|
+
|
19
|
+
# protected
|
20
|
+
|
21
|
+
# The path used after resending confirmation instructions.
|
22
|
+
# def after_resending_confirmation_instructions_path_for(resource_name)
|
23
|
+
# super(resource_name)
|
24
|
+
# end
|
25
|
+
|
26
|
+
# The path used after confirmation.
|
27
|
+
# def after_confirmation_path_for(resource_name, resource)
|
28
|
+
# super(resource_name, resource)
|
29
|
+
# end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class <%= @scope_prefix %>OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
4
|
+
# You should configure your model like this:
|
5
|
+
# devise :omniauthable, omniauth_providers: [:twitter]
|
6
|
+
|
7
|
+
# You should also create an action method in this controller like this:
|
8
|
+
# def twitter
|
9
|
+
# end
|
10
|
+
|
11
|
+
# More info at:
|
12
|
+
# https://github.com/plataformatec/devise#omniauth
|
13
|
+
|
14
|
+
# GET|POST /resource/auth/twitter
|
15
|
+
# def passthru
|
16
|
+
# super
|
17
|
+
# end
|
18
|
+
|
19
|
+
# GET|POST /users/auth/twitter/callback
|
20
|
+
# def failure
|
21
|
+
# super
|
22
|
+
# end
|
23
|
+
|
24
|
+
# protected
|
25
|
+
|
26
|
+
# The path used when OmniAuth fails
|
27
|
+
# def after_omniauth_failure_path_for(scope)
|
28
|
+
# super(scope)
|
29
|
+
# end
|
30
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class <%= @scope_prefix %>PasswordsController < Devise::PasswordsController
|
4
|
+
# GET /resource/password/new
|
5
|
+
# def new
|
6
|
+
# super
|
7
|
+
# end
|
8
|
+
|
9
|
+
# POST /resource/password
|
10
|
+
# def create
|
11
|
+
# super
|
12
|
+
# end
|
13
|
+
|
14
|
+
# GET /resource/password/edit?reset_password_token=abcdef
|
15
|
+
# def edit
|
16
|
+
# super
|
17
|
+
# end
|
18
|
+
|
19
|
+
# PUT /resource/password
|
20
|
+
# def update
|
21
|
+
# super
|
22
|
+
# end
|
23
|
+
|
24
|
+
# protected
|
25
|
+
|
26
|
+
# def after_resetting_password_path_for(resource)
|
27
|
+
# super(resource)
|
28
|
+
# end
|
29
|
+
|
30
|
+
# The path used after sending reset password instructions
|
31
|
+
# def after_sending_reset_password_instructions_path_for(resource_name)
|
32
|
+
# super(resource_name)
|
33
|
+
# end
|
34
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class <%= @scope_prefix %>RegistrationsController < Devise::RegistrationsController
|
4
|
+
# before_action :configure_sign_up_params, only: [:create]
|
5
|
+
# before_action :configure_account_update_params, only: [:update]
|
6
|
+
|
7
|
+
# GET /resource/sign_up
|
8
|
+
# def new
|
9
|
+
# super
|
10
|
+
# end
|
11
|
+
|
12
|
+
# POST /resource
|
13
|
+
# def create
|
14
|
+
# super
|
15
|
+
# end
|
16
|
+
|
17
|
+
# GET /resource/edit
|
18
|
+
# def edit
|
19
|
+
# super
|
20
|
+
# end
|
21
|
+
|
22
|
+
# PUT /resource
|
23
|
+
# def update
|
24
|
+
# super
|
25
|
+
# end
|
26
|
+
|
27
|
+
# DELETE /resource
|
28
|
+
# def destroy
|
29
|
+
# super
|
30
|
+
# end
|
31
|
+
|
32
|
+
# GET /resource/cancel
|
33
|
+
# Forces the session data which is usually expired after sign
|
34
|
+
# in to be expired now. This is useful if the user wants to
|
35
|
+
# cancel oauth signing in/up in the middle of the process,
|
36
|
+
# removing all OAuth session data.
|
37
|
+
# def cancel
|
38
|
+
# super
|
39
|
+
# end
|
40
|
+
|
41
|
+
# protected
|
42
|
+
|
43
|
+
# If you have extra params to permit, append them to the sanitizer.
|
44
|
+
# def configure_sign_up_params
|
45
|
+
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
|
46
|
+
# end
|
47
|
+
|
48
|
+
# If you have extra params to permit, append them to the sanitizer.
|
49
|
+
# def configure_account_update_params
|
50
|
+
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
|
51
|
+
# end
|
52
|
+
|
53
|
+
# The path used after sign up.
|
54
|
+
# def after_sign_up_path_for(resource)
|
55
|
+
# super(resource)
|
56
|
+
# end
|
57
|
+
|
58
|
+
# The path used after sign up for inactive accounts.
|
59
|
+
# def after_inactive_sign_up_path_for(resource)
|
60
|
+
# super(resource)
|
61
|
+
# end
|
62
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class <%= @scope_prefix %>SessionsController < Devise::SessionsController
|
4
|
+
# before_action :configure_sign_in_params, only: [:create]
|
5
|
+
|
6
|
+
# GET /resource/sign_in
|
7
|
+
# def new
|
8
|
+
# super
|
9
|
+
# end
|
10
|
+
|
11
|
+
# POST /resource/sign_in
|
12
|
+
# def create
|
13
|
+
# super
|
14
|
+
# end
|
15
|
+
|
16
|
+
# DELETE /resource/sign_out
|
17
|
+
# def destroy
|
18
|
+
# super
|
19
|
+
# end
|
20
|
+
|
21
|
+
# protected
|
22
|
+
|
23
|
+
# If you have extra params to permit, append them to the sanitizer.
|
24
|
+
# def configure_sign_in_params
|
25
|
+
# devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
|
26
|
+
# end
|
27
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class <%= @scope_prefix %>UnlocksController < Devise::UnlocksController
|
4
|
+
# GET /resource/unlock/new
|
5
|
+
# def new
|
6
|
+
# super
|
7
|
+
# end
|
8
|
+
|
9
|
+
# POST /resource/unlock
|
10
|
+
# def create
|
11
|
+
# super
|
12
|
+
# end
|
13
|
+
|
14
|
+
# GET /resource/unlock?unlock_token=abcdef
|
15
|
+
# def show
|
16
|
+
# super
|
17
|
+
# end
|
18
|
+
|
19
|
+
# protected
|
20
|
+
|
21
|
+
# The path used after sending unlock password instructions
|
22
|
+
# def after_sending_unlock_instructions_path_for(resource)
|
23
|
+
# super(resource)
|
24
|
+
# end
|
25
|
+
|
26
|
+
# The path used after unlocking the resource
|
27
|
+
# def after_unlock_path_for(resource)
|
28
|
+
# super(resource)
|
29
|
+
# end
|
30
|
+
end
|