kingsman 0.0.0.beta → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -4
  3. data/app/controllers/kingsman/confirmations_controller.rb +54 -0
  4. data/app/controllers/kingsman/omniauth_callbacks_controller.rb +36 -0
  5. data/app/controllers/kingsman/passwords_controller.rb +83 -0
  6. data/app/controllers/kingsman/registrations_controller.rb +168 -0
  7. data/app/controllers/kingsman/sessions_controller.rb +83 -0
  8. data/app/controllers/kingsman/unlocks_controller.rb +52 -0
  9. data/app/controllers/kingsman_controller.rb +252 -0
  10. data/app/jobs/application_job.rb +2 -0
  11. data/app/mailers/kingsman/mailer.rb +30 -0
  12. data/app/views/kingsman/confirmations/new.html.erb +16 -0
  13. data/app/views/kingsman/home/index.html.erb +1 -0
  14. data/app/views/kingsman/mailer/confirmation_instructions.html.erb +5 -0
  15. data/app/views/kingsman/mailer/email_changed.html.erb +7 -0
  16. data/app/views/kingsman/mailer/password_change.html.erb +3 -0
  17. data/app/views/kingsman/mailer/reset_password_instructions.html.erb +8 -0
  18. data/app/views/kingsman/mailer/unlock_instructions.html.erb +7 -0
  19. data/app/views/kingsman/passwords/edit.html.erb +25 -0
  20. data/app/views/kingsman/passwords/new.html.erb +16 -0
  21. data/app/views/kingsman/registrations/edit.html.erb +42 -0
  22. data/app/views/kingsman/registrations/new.html.erb +29 -0
  23. data/app/views/kingsman/sessions/new.html.erb +26 -0
  24. data/app/views/kingsman/shared/_error_messages.html.erb +15 -0
  25. data/app/views/kingsman/shared/_links.html.erb +25 -0
  26. data/app/views/kingsman/unlocks/new.html.erb +16 -0
  27. data/app/views/kingsman/up/index.html.erb +11 -0
  28. data/config/application.rb +0 -0
  29. data/config/locales/en.yml +63 -0
  30. data/config.ru +6 -0
  31. data/lib/generators/active_record/kingsman_generator.rb +127 -0
  32. data/lib/generators/active_record/templates/migration.rb +20 -0
  33. data/lib/generators/active_record/templates/migration_existing.rb +27 -0
  34. data/lib/generators/kingsman/controllers_generator.rb +46 -0
  35. data/lib/generators/kingsman/install_generator.rb +42 -0
  36. data/lib/generators/kingsman/kingsman_generator.rb +28 -0
  37. data/lib/generators/kingsman/orm_helpers.rb +40 -0
  38. data/lib/generators/kingsman/views_generator.rb +145 -0
  39. data/lib/generators/mongoid/kingsman_generator.rb +57 -0
  40. data/lib/generators/templates/README +36 -0
  41. data/lib/generators/templates/controllers/README +14 -0
  42. data/lib/generators/templates/controllers/confirmations_controller.rb +30 -0
  43. data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +30 -0
  44. data/lib/generators/templates/controllers/passwords_controller.rb +34 -0
  45. data/lib/generators/templates/controllers/registrations_controller.rb +62 -0
  46. data/lib/generators/templates/controllers/sessions_controller.rb +27 -0
  47. data/lib/generators/templates/controllers/unlocks_controller.rb +30 -0
  48. data/lib/generators/templates/kingsman.rb +313 -0
  49. data/lib/generators/templates/markerb/confirmation_instructions.markerb +5 -0
  50. data/lib/generators/templates/markerb/email_changed.markerb +7 -0
  51. data/lib/generators/templates/markerb/password_change.markerb +3 -0
  52. data/lib/generators/templates/markerb/reset_password_instructions.markerb +8 -0
  53. data/lib/generators/templates/markerb/unlock_instructions.markerb +7 -0
  54. data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +20 -0
  55. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +27 -0
  56. data/lib/generators/templates/simple_form_for/passwords/new.html.erb +18 -0
  57. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +35 -0
  58. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +25 -0
  59. data/lib/generators/templates/simple_form_for/sessions/new.html.erb +20 -0
  60. data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +19 -0
  61. data/lib/kingsman/autoloader.rb +31 -0
  62. data/lib/kingsman/controllers/helpers.rb +221 -0
  63. data/lib/kingsman/controllers/rememberable.rb +57 -0
  64. data/lib/kingsman/controllers/responder.rb +35 -0
  65. data/lib/kingsman/controllers/scoped_views.rb +19 -0
  66. data/lib/kingsman/controllers/sign_in_out.rb +112 -0
  67. data/lib/kingsman/controllers/store_location.rb +76 -0
  68. data/lib/kingsman/controllers/url_helpers.rb +72 -0
  69. data/lib/kingsman/delegator.rb +18 -0
  70. data/lib/kingsman/encryptor.rb +19 -0
  71. data/lib/kingsman/failure_app.rb +280 -0
  72. data/lib/kingsman/hooks/activatable.rb +12 -0
  73. data/lib/kingsman/hooks/csrf_cleaner.rb +14 -0
  74. data/lib/kingsman/hooks/forgetable.rb +11 -0
  75. data/lib/kingsman/hooks/lockable.rb +9 -0
  76. data/lib/kingsman/hooks/proxy.rb +23 -0
  77. data/lib/kingsman/hooks/rememberable.rb +9 -0
  78. data/lib/kingsman/hooks/timeoutable.rb +35 -0
  79. data/lib/kingsman/hooks/trackable.rb +11 -0
  80. data/lib/kingsman/hooks.rb +6 -0
  81. data/lib/kingsman/jets/routes.rb +195 -0
  82. data/lib/kingsman/jets/warden_compat.rb +15 -0
  83. data/lib/kingsman/jets.rb +39 -0
  84. data/lib/kingsman/mailers/helpers.rb +93 -0
  85. data/lib/kingsman/mapping.rb +148 -0
  86. data/lib/kingsman/models/authenticatable.rb +310 -0
  87. data/lib/kingsman/models/confirmable.rb +369 -0
  88. data/lib/kingsman/models/database_authenticatable.rb +206 -0
  89. data/lib/kingsman/models/lockable.rb +214 -0
  90. data/lib/kingsman/models/omniauthable.rb +29 -0
  91. data/lib/kingsman/models/recoverable.rb +156 -0
  92. data/lib/kingsman/models/registerable.rb +29 -0
  93. data/lib/kingsman/models/rememberable.rb +158 -0
  94. data/lib/kingsman/models/timeoutable.rb +45 -0
  95. data/lib/kingsman/models/trackable.rb +51 -0
  96. data/lib/kingsman/models/validatable.rb +68 -0
  97. data/lib/kingsman/models.rb +122 -0
  98. data/lib/kingsman/modules.rb +33 -0
  99. data/lib/kingsman/omniauth/config.rb +47 -0
  100. data/lib/kingsman/omniauth/url_helpers.rb +28 -0
  101. data/lib/kingsman/omniauth.rb +20 -0
  102. data/lib/kingsman/orm/active_record.rb +13 -0
  103. data/lib/kingsman/orm/mongoid.rb +8 -0
  104. data/lib/kingsman/orm.rb +37 -0
  105. data/lib/kingsman/parameter_filter.rb +44 -0
  106. data/lib/kingsman/parameter_sanitizer.rb +173 -0
  107. data/lib/kingsman/secret_key_finder.rb +27 -0
  108. data/lib/kingsman/strategies/authenticatable.rb +178 -0
  109. data/lib/kingsman/strategies/base.rb +22 -0
  110. data/lib/kingsman/strategies/database_authenticatable.rb +31 -0
  111. data/lib/kingsman/strategies/rememberable.rb +67 -0
  112. data/lib/kingsman/token_generator.rb +32 -0
  113. data/lib/kingsman/version.rb +1 -1
  114. data/lib/kingsman.rb +427 -3
  115. metadata +289 -11
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ class <%= @scope_prefix %>RegistrationsController < Kingsman::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
+ # kingsman_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
+ # kingsman_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 < Kingsman::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
+ # kingsman_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 < Kingsman::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
@@ -0,0 +1,313 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Assuming you have not yet modified this file, each configuration option below
4
+ # is set to its default value. Note that some are commented out while others
5
+ # are not: uncommented lines are intended to protect your configuration from
6
+ # breaking changes in upgrades (i.e., in the event that future versions of
7
+ # Kingsman change the default values for those options).
8
+ #
9
+ # Use this hook to configure kingsman mailer, warden hooks and so forth.
10
+ # Many of these configuration options can be set straight in your model.
11
+ Kingsman.setup do |config|
12
+ # The secret key used by Kingsman. Kingsman uses this key to generate
13
+ # random tokens. Changing this key will render invalid all existing
14
+ # confirmation, reset password and unlock tokens in the database.
15
+ # Kingsman will use the `secret_key_base` as its `secret_key`
16
+ # by default. You can change it below and use your own secret key.
17
+ # config.secret_key = '<%%= SecureRandom.hex(64) %>'
18
+
19
+ # ==> Controller configuration
20
+ # Configure the parent class to the kingsman controllers.
21
+ # config.parent_controller = 'KingsmanController'
22
+
23
+ # ==> Mailer Configuration
24
+ # Configure the e-mail address which will be shown in Kingsman::Mailer,
25
+ # note that it will be overwritten if you use your own mailer class
26
+ # with default "from" parameter.
27
+ config.mailer_sender = 'please-change-me-at-config-initializers-kingsman@example.com'
28
+
29
+ # Configure the class responsible to send e-mails.
30
+ # config.mailer = 'Kingsman::Mailer'
31
+
32
+ # Configure the parent class responsible to send e-mails.
33
+ # config.parent_mailer = 'ActionMailer::Base'
34
+
35
+ # ==> ORM configuration
36
+ # Load and configure the ORM. Supports :active_record (default) and
37
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
38
+ # available as additional gems.
39
+ require 'kingsman/orm/<%= options[:orm] %>'
40
+
41
+ # ==> Configuration for any authentication mechanism
42
+ # Configure which keys are used when authenticating a user. The default is
43
+ # just :email. You can configure it to use [:username, :subdomain], so for
44
+ # authenticating a user, both parameters are required. Remember that those
45
+ # parameters are used only when authenticating and not when retrieving from
46
+ # session. If you need permissions, you should implement that in a before filter.
47
+ # You can also supply a hash where the value is a boolean determining whether
48
+ # or not authentication should be aborted when the value is not present.
49
+ # config.authentication_keys = [:email]
50
+
51
+ # Configure parameters from the request object used for authentication. Each entry
52
+ # given should be a request method and it will automatically be passed to the
53
+ # find_for_authentication method and considered in your model lookup. For instance,
54
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
55
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
56
+ # config.request_keys = []
57
+
58
+ # Configure which authentication keys should be case-insensitive.
59
+ # These keys will be downcased upon creating or modifying a user and when used
60
+ # to authenticate or find a user. Default is :email.
61
+ config.case_insensitive_keys = [:email]
62
+
63
+ # Configure which authentication keys should have whitespace stripped.
64
+ # These keys will have whitespace before and after removed upon creating or
65
+ # modifying a user and when used to authenticate or find a user. Default is :email.
66
+ config.strip_whitespace_keys = [:email]
67
+
68
+ # Tell if authentication through request.params is enabled. True by default.
69
+ # It can be set to an array that will enable params authentication only for the
70
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
71
+ # enable it only for database (email + password) authentication.
72
+ # config.params_authenticatable = true
73
+
74
+ # Tell if authentication through HTTP Auth is enabled. False by default.
75
+ # It can be set to an array that will enable http authentication only for the
76
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
77
+ # enable it only for database authentication.
78
+ # For API-only applications to support authentication "out-of-the-box", you will likely want to
79
+ # enable this with :database unless you are using a custom strategy.
80
+ # The supported strategies are:
81
+ # :database = Support basic authentication with authentication key + password
82
+ # config.http_authenticatable = false
83
+
84
+ # If 401 status code should be returned for AJAX requests. True by default.
85
+ # config.http_authenticatable_on_xhr = true
86
+
87
+ # The realm used in Http Basic Authentication. 'Application' by default.
88
+ # config.http_authentication_realm = 'Application'
89
+
90
+ # It will change confirmation, password recovery and other workflows
91
+ # to behave the same regardless if the e-mail provided was right or wrong.
92
+ # Does not affect registerable.
93
+ # config.paranoid = true
94
+
95
+ # By default Kingsman will store the user in session. You can skip storage for
96
+ # particular strategies by setting this option.
97
+ # Notice that if you are skipping storage for all authentication paths, you
98
+ # may want to disable generating routes to Kingsman's sessions controller by
99
+ # passing skip: :sessions to `kingsman_for` in your config/routes.rb
100
+ config.skip_session_storage = [:http_auth]
101
+
102
+ # By default, Kingsman cleans up the CSRF token on authentication to
103
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
104
+ # requests for sign in and sign up, you need to get a new CSRF token
105
+ # from the server. You can disable this option at your own risk.
106
+ # config.clean_up_csrf_token_on_authentication = true
107
+
108
+ # When false, Kingsman will not attempt to reload routes on eager load.
109
+ # This can reduce the time taken to boot the app but if your application
110
+ # requires the Kingsman mappings to be loaded during boot time the application
111
+ # won't boot properly.
112
+ # config.reload_routes = true
113
+
114
+ # ==> Configuration for :database_authenticatable
115
+ # For bcrypt, this is the cost for hashing the password and defaults to 12. If
116
+ # using other algorithms, it sets how many times you want the password to be hashed.
117
+ # The number of stretches used for generating the hashed password are stored
118
+ # with the hashed password. This allows you to change the stretches without
119
+ # invalidating existing passwords.
120
+ #
121
+ # Limiting the stretches to just one in testing will increase the performance of
122
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
123
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
124
+ # algorithm), the cost increases exponentially with the number of stretches (e.g.
125
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
126
+ config.stretches = Jets.env.test? ? 1 : 12
127
+
128
+ # Set up a pepper to generate the hashed password.
129
+ # config.pepper = '<%%= SecureRandom.hex(64) %>'
130
+
131
+ # Send a notification to the original email when the user's email is changed.
132
+ # config.send_email_changed_notification = false
133
+
134
+ # Send a notification email when the user's password is changed.
135
+ # config.send_password_change_notification = false
136
+
137
+ # ==> Configuration for :confirmable
138
+ # A period that the user is allowed to access the website even without
139
+ # confirming their account. For instance, if set to 2.days, the user will be
140
+ # able to access the website for two days without confirming their account,
141
+ # access will be blocked just in the third day.
142
+ # You can also set it to nil, which will allow the user to access the website
143
+ # without confirming their account.
144
+ # Default is 0.days, meaning the user cannot access the website without
145
+ # confirming their account.
146
+ # config.allow_unconfirmed_access_for = 2.days
147
+
148
+ # A period that the user is allowed to confirm their account before their
149
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
150
+ # their account within 3 days after the mail was sent, but on the fourth day
151
+ # their account can't be confirmed with the token any more.
152
+ # Default is nil, meaning there is no restriction on how long a user can take
153
+ # before confirming their account.
154
+ # config.confirm_within = 3.days
155
+
156
+ # If true, requires any email changes to be confirmed (exactly the same way as
157
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
158
+ # db field (see migrations). Until confirmed, new email is stored in
159
+ # unconfirmed_email column, and copied to email column on successful confirmation.
160
+ config.reconfirmable = true
161
+
162
+ # Defines which key will be used when confirming an account
163
+ # config.confirmation_keys = [:email]
164
+
165
+ # ==> Configuration for :rememberable
166
+ # The time the user will be remembered without asking for credentials again.
167
+ # config.remember_for = 2.weeks
168
+
169
+ # Invalidates all the remember me tokens when the user signs out.
170
+ config.expire_all_remember_me_on_sign_out = true
171
+
172
+ # If true, extends the user's remember period when remembered via cookie.
173
+ # config.extend_remember_period = false
174
+
175
+ # Options to be passed to the created cookie. For instance, you can set
176
+ # secure: true in order to force SSL only cookies.
177
+ # config.rememberable_options = {}
178
+
179
+ # ==> Configuration for :validatable
180
+ # Range for password length.
181
+ config.password_length = 6..128
182
+
183
+ # Email regex used to validate email formats. It simply asserts that
184
+ # one (and only one) @ exists in the given string. This is mainly
185
+ # to give user feedback and not to assert the e-mail validity.
186
+ config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
187
+
188
+ # ==> Configuration for :timeoutable
189
+ # The time you want to timeout the user session without activity. After this
190
+ # time the user will be asked for credentials again. Default is 30 minutes.
191
+ # config.timeout_in = 30.minutes
192
+
193
+ # ==> Configuration for :lockable
194
+ # Defines which strategy will be used to lock an account.
195
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
196
+ # :none = No lock strategy. You should handle locking by yourself.
197
+ # config.lock_strategy = :failed_attempts
198
+
199
+ # Defines which key will be used when locking and unlocking an account
200
+ # config.unlock_keys = [:email]
201
+
202
+ # Defines which strategy will be used to unlock an account.
203
+ # :email = Sends an unlock link to the user email
204
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
205
+ # :both = Enables both strategies
206
+ # :none = No unlock strategy. You should handle unlocking by yourself.
207
+ # config.unlock_strategy = :both
208
+
209
+ # Number of authentication tries before locking an account if lock_strategy
210
+ # is failed attempts.
211
+ # config.maximum_attempts = 20
212
+
213
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
214
+ # config.unlock_in = 1.hour
215
+
216
+ # Warn on the last attempt before the account is locked.
217
+ # config.last_attempt_warning = true
218
+
219
+ # ==> Configuration for :recoverable
220
+ #
221
+ # Defines which key will be used when recovering the password for an account
222
+ # config.reset_password_keys = [:email]
223
+
224
+ # Time interval you can reset your password with a reset password key.
225
+ # Don't put a too small interval or your users won't have the time to
226
+ # change their passwords.
227
+ config.reset_password_within = 6.hours
228
+
229
+ # When set to false, does not sign a user in automatically after their password is
230
+ # reset. Defaults to true, so a user is signed in automatically after a reset.
231
+ # config.sign_in_after_reset_password = true
232
+
233
+ # ==> Configuration for :encryptable
234
+ # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
235
+ # You can use :sha1, :sha512 or algorithms from others authentication tools as
236
+ # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
237
+ # for default behavior) and :restful_authentication_sha1 (then you should set
238
+ # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
239
+ #
240
+ # Require the `kingsman-encryptable` gem when using anything other than bcrypt
241
+ # config.encryptor = :sha512
242
+
243
+ # ==> Scopes configuration
244
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
245
+ # "users/sessions/new". It's turned off by default because it's slower if you
246
+ # are using only default views.
247
+ # config.scoped_views = false
248
+
249
+ # Configure the default scope given to Warden. By default it's the first
250
+ # kingsman role declared in your routes (usually :user).
251
+ # config.default_scope = :user
252
+
253
+ # Set this configuration to false if you want /users/sign_out to sign out
254
+ # only the current scope. By default, Kingsman signs out all scopes.
255
+ # config.sign_out_all_scopes = true
256
+
257
+ # ==> Navigation configuration
258
+ # Lists the formats that should be treated as navigational. Formats like
259
+ # :html should redirect to the sign in page when the user does not have
260
+ # access, but formats like :xml or :json, should return 401.
261
+ #
262
+ # If you have any extra navigational formats, like :iphone or :mobile, you
263
+ # should add them to the navigational formats lists.
264
+ #
265
+ # The "*/*" below is required to match Internet Explorer requests.
266
+ # config.navigational_formats = ['*/*', :html, :turbo_stream]
267
+
268
+ # The default HTTP method used to sign out a resource. Default is :delete.
269
+ config.sign_out_via = :delete
270
+
271
+ # ==> OmniAuth
272
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
273
+ # up on your models and hooks.
274
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
275
+
276
+ # ==> Warden configuration
277
+ # If you want to use other strategies, that are not supported by Kingsman, or
278
+ # change the failure app, you can configure them inside the config.warden block.
279
+ #
280
+ # config.warden do |manager|
281
+ # manager.intercept_401 = false
282
+ # manager.default_strategies(scope: :user).unshift :some_external_strategy
283
+ # end
284
+
285
+ # ==> Mountable engine configurations
286
+ # When using Kingsman inside an engine, let's call it `MyEngine`, and this engine
287
+ # is mountable, there are some extra configurations to be taken into account.
288
+ # The following options are available, assuming the engine is mounted as:
289
+ #
290
+ # mount MyEngine, at: '/my_engine'
291
+ #
292
+ # The router that invoked `kingsman_for`, in the example above, would be:
293
+ # config.router_name = :my_engine
294
+ #
295
+ # When using OmniAuth, Kingsman cannot automatically set OmniAuth path,
296
+ # so you need to do it manually. For the users scope, it would be:
297
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
298
+
299
+ # ==> Hotwire/Turbo configuration
300
+ # When using Kingsman with Hotwire/Turbo, the http status for error responses
301
+ # and some redirects must match the following. The default in Kingsman for existing
302
+ # apps is `200 OK` and `302 Found` respectively, but new apps are generated with
303
+ # these new defaults that match Hotwire/Turbo behavior.
304
+ # Note: These might become the new default in future versions of Kingsman.
305
+ config.responder.error_status = :unprocessable_entity
306
+ config.responder.redirect_status = :see_other
307
+
308
+ # ==> Configuration for :registerable
309
+
310
+ # When set to false, does not sign a user in automatically after their password is
311
+ # changed. Defaults to true, so a user is signed in automatically after changing a password.
312
+ # config.sign_in_after_change_password = true
313
+ end
@@ -0,0 +1,5 @@
1
+ Welcome <%= @email %>!
2
+
3
+ You can confirm your account through the link below:
4
+
5
+ [Confirm my account](<%= confirmation_url(@resource, confirmation_token: @token) %>)
@@ -0,0 +1,7 @@
1
+ Hello <%= @email %>!
2
+
3
+ <% if @resource.try(:unconfirmed_email?) %>
4
+ We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.
5
+ <% else %>
6
+ We're contacting you to notify you that your email has been changed to <%= @resource.email %>.
7
+ <% end %>
@@ -0,0 +1,3 @@
1
+ Hello <%= @resource.email %>!
2
+
3
+ We're contacting you to notify you that your password has been changed.
@@ -0,0 +1,8 @@
1
+ Hello <%= @resource.email %>!
2
+
3
+ Someone has requested a link to change your password, and you can do this through the link below.
4
+
5
+ [Change my password](<%= edit_password_url(@resource, reset_password_token: @token) %>)
6
+
7
+ If you didn't request this, please ignore this email.
8
+ Your password won't change until you access the link above and create a new one.
@@ -0,0 +1,7 @@
1
+ Hello <%= @resource.email %>!
2
+
3
+ Your account has been locked due to an excessive number of unsuccessful sign in attempts.
4
+
5
+ Click the link below to unlock your account:
6
+
7
+ [Unlock my account](<%= unlock_url(@resource, unlock_token: @token) %>)
@@ -0,0 +1,20 @@
1
+ <h2>Resend confirmation instructions</h2>
2
+
3
+ <%= simple_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
4
+ <%= f.error_notification %>
5
+ <%= f.full_error :confirmation_token %>
6
+
7
+ <div class="form-inputs">
8
+ <%= f.input :email,
9
+ required: true,
10
+ autofocus: true,
11
+ value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email),
12
+ input_html: { autocomplete: "email" } %>
13
+ </div>
14
+
15
+ <div class="form-actions">
16
+ <%= f.button :submit, "Resend confirmation instructions" %>
17
+ </div>
18
+ <% end %>
19
+
20
+ <%= render "kingsman/shared/links" %>
@@ -0,0 +1,27 @@
1
+ <h2>Change your password</h2>
2
+
3
+ <%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
4
+ <%= f.error_notification %>
5
+
6
+ <%= f.input :reset_password_token, as: :hidden %>
7
+ <%= f.full_error :reset_password_token %>
8
+
9
+ <div class="form-inputs">
10
+ <%= f.input :password,
11
+ label: "New password",
12
+ required: true,
13
+ autofocus: true,
14
+ hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length),
15
+ input_html: { autocomplete: "new-password" } %>
16
+ <%= f.input :password_confirmation,
17
+ label: "Confirm your new password",
18
+ required: true,
19
+ input_html: { autocomplete: "new-password" } %>
20
+ </div>
21
+
22
+ <div class="form-actions">
23
+ <%= f.button :submit, "Change my password" %>
24
+ </div>
25
+ <% end %>
26
+
27
+ <%= render "kingsman/shared/links" %>
@@ -0,0 +1,18 @@
1
+ <h2>Forgot your password?</h2>
2
+
3
+ <%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
4
+ <%= f.error_notification %>
5
+
6
+ <div class="form-inputs">
7
+ <%= f.input :email,
8
+ required: true,
9
+ autofocus: true,
10
+ input_html: { autocomplete: "email" } %>
11
+ </div>
12
+
13
+ <div class="form-actions">
14
+ <%= f.button :submit, "Send me reset password instructions" %>
15
+ </div>
16
+ <% end %>
17
+
18
+ <%= render "kingsman/shared/links" %>
@@ -0,0 +1,35 @@
1
+ <h2>Edit <%= resource_name.to_s.humanize %></h2>
2
+
3
+ <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
4
+ <%= f.error_notification %>
5
+
6
+ <div class="form-inputs">
7
+ <%= f.input :email, required: true, autofocus: true %>
8
+
9
+ <% if kingsman_mapping.confirmable? && resource.pending_reconfirmation? %>
10
+ <p>Currently waiting confirmation for: <%= resource.unconfirmed_email %></p>
11
+ <% end %>
12
+
13
+ <%= f.input :password,
14
+ hint: "leave it blank if you don't want to change it",
15
+ required: false,
16
+ input_html: { autocomplete: "new-password" } %>
17
+ <%= f.input :password_confirmation,
18
+ required: false,
19
+ input_html: { autocomplete: "new-password" } %>
20
+ <%= f.input :current_password,
21
+ hint: "we need your current password to confirm your changes",
22
+ required: true,
23
+ input_html: { autocomplete: "current-password" } %>
24
+ </div>
25
+
26
+ <div class="form-actions">
27
+ <%= f.button :submit, "Update" %>
28
+ </div>
29
+ <% end %>
30
+
31
+ <h3>Cancel my account</h3>
32
+
33
+ <div>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?" }, method: :delete %></div>
34
+
35
+ <%= link_to "Back", :back %>
@@ -0,0 +1,25 @@
1
+ <h2>Sign up</h2>
2
+
3
+ <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
4
+ <%= f.error_notification %>
5
+
6
+ <div class="form-inputs">
7
+ <%= f.input :email,
8
+ required: true,
9
+ autofocus: true,
10
+ input_html: { autocomplete: "email" }%>
11
+ <%= f.input :password,
12
+ required: true,
13
+ hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length),
14
+ input_html: { autocomplete: "new-password" } %>
15
+ <%= f.input :password_confirmation,
16
+ required: true,
17
+ input_html: { autocomplete: "new-password" } %>
18
+ </div>
19
+
20
+ <div class="form-actions">
21
+ <%= f.button :submit, "Sign up" %>
22
+ </div>
23
+ <% end %>
24
+
25
+ <%= render "kingsman/shared/links" %>
@@ -0,0 +1,20 @@
1
+ <h2>Log in</h2>
2
+
3
+ <%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
4
+ <div class="form-inputs">
5
+ <%= f.input :email,
6
+ required: false,
7
+ autofocus: true,
8
+ input_html: { autocomplete: "email" } %>
9
+ <%= f.input :password,
10
+ required: false,
11
+ input_html: { autocomplete: "current-password" } %>
12
+ <%= f.input :remember_me, as: :boolean if kingsman_mapping.rememberable? %>
13
+ </div>
14
+
15
+ <div class="form-actions">
16
+ <%= f.button :submit, "Log in" %>
17
+ </div>
18
+ <% end %>
19
+
20
+ <%= render "kingsman/shared/links" %>
@@ -0,0 +1,19 @@
1
+ <h2>Resend unlock instructions</h2>
2
+
3
+ <%= simple_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
4
+ <%= f.error_notification %>
5
+ <%= f.full_error :unlock_token %>
6
+
7
+ <div class="form-inputs">
8
+ <%= f.input :email,
9
+ required: true,
10
+ autofocus: true,
11
+ input_html: { autocomplete: "email" } %>
12
+ </div>
13
+
14
+ <div class="form-actions">
15
+ <%= f.button :submit, "Resend unlock instructions" %>
16
+ </div>
17
+ <% end %>
18
+
19
+ <%= render "kingsman/shared/links" %>