nyauth 0.2.8 → 0.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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -4
  3. data/app/controllers/concerns/nyauth/client_concern.rb +21 -9
  4. data/app/controllers/concerns/nyauth/{application_concern.rb → controller_concern.rb} +3 -1
  5. data/app/controllers/concerns/nyauth/session_concern.rb +2 -1
  6. data/app/controllers/nyauth/confirmation_requests_controller.rb +3 -4
  7. data/app/controllers/nyauth/confirmations_controller.rb +3 -4
  8. data/app/controllers/nyauth/passwords_controller.rb +5 -7
  9. data/app/controllers/nyauth/registrations_controller.rb +4 -5
  10. data/app/controllers/nyauth/reset_password_requests_controller.rb +3 -4
  11. data/app/controllers/nyauth/reset_passwords_controller.rb +5 -6
  12. data/app/controllers/nyauth/sessions_controller.rb +9 -7
  13. data/app/helpers/nyauth/application_helper.rb +6 -6
  14. data/app/views/nyauth/confirmation_requests/new.html.erb +1 -1
  15. data/app/views/nyauth/passwords/edit.html.erb +1 -1
  16. data/app/views/nyauth/registrations/new.html.erb +1 -1
  17. data/app/views/nyauth/reset_password_requests/new.html.erb +1 -1
  18. data/app/views/nyauth/reset_passwords/edit.html.erb +1 -1
  19. data/app/views/nyauth/sessions/new.html.erb +1 -1
  20. data/lib/nyauth/test/macros.rb +2 -0
  21. data/lib/nyauth/version.rb +1 -1
  22. data/spec/dummy/app/controllers/application_controller.rb +1 -5
  23. data/spec/dummy/app/controllers/posts_controller.rb +2 -1
  24. data/spec/dummy/app/views/posts/index.html.erb +0 -0
  25. data/spec/dummy/db/test.sqlite3 +0 -0
  26. data/spec/dummy/log/development.log +360 -4
  27. data/spec/dummy/log/test.log +8658 -0
  28. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/00R4IbuMWUgW0TswtkCnDqB8MUJqvz76FgkmbrLPTd8.cache +0 -0
  29. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/1-v7tFLPkD6uyCpAKjAKORwPg5YalyY-SYwjNGTiHQo.cache +1 -0
  30. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/122B1KZyQmgyJoX7uc4JINcUDUmcMHJsbf5JopBIpSg.cache +2 -0
  31. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/2W23wCoDaNvkpc-htXrPJ_4wwRXsCB8sDUi-vlecXRY.cache +1 -0
  32. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/8UAh9fJot2eROIl2PFflmIp2Q0G3oNNzBxCYx6AWaTw.cache +3 -0
  33. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/8Ze9kDXrEQxOBazUvSE0NM5zLGZnHFsDskzK_P47vk4.cache +1 -0
  34. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Ald0qisxC6krU6CCGUtsVQJwZ786HWf2a4VJnhi2Lrw.cache +1 -0
  35. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Bx8MbffT9WQGgl0DcTM5n11UlQabeTzIyqKGm2snGus.cache +1 -0
  36. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/CjFGeOmtoOvDUwEi78Mx3PtuchpMqlfecazo-n8RsAQ.cache +0 -0
  37. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/DK6c5xJ8kSeXSqJlndPmMohu6AMbxDTYw3amSuVkoTs.cache +2 -0
  38. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/E16A8LE9OYp6k-WBc2Egdmn6XL_-ipcmDOYBOfBITqs.cache +2 -0
  39. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/EGILbSm92CBXW0Z6Mp6o2YygxS4b8Hhd2CW8igzKuRM.cache +1 -0
  40. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/FIPwj786RByADaWtmUkp2eeWQvQ_QmX1ER1sGGOKgqo.cache +1 -0
  41. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Fo9EHolUACmT7eKdJVmIzktbVgFRBZQkcCGHFfpD7u0.cache +1 -0
  42. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/KiPxsMrAEr8OMX4H_Q8MSOgJ0PuFTQf2yX0S4kZsDVs.cache +1 -0
  43. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Tpj_x0CkqGAEMDgH-JGBkdkajznkLbbiVVZOxEqURxU.cache +0 -0
  44. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/ZM48tpiRiDxrKqKUvohWJfOeqwp5RsXgtKY84fW-qEE.cache +0 -0
  45. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/ZcwAlVnn77peLsFoZbCh7F7wpmxPhsehRs1frol6gfU.cache +1 -0
  46. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/h1z_izpQoHamMnv_RoNWN6gT2x3tY11ndWa7uVWkiaE.cache +0 -0
  47. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/k-V4Qz1zxawVTQoo00igdXRPgv4xOiV8fQsQtj8uDhA.cache +0 -0
  48. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lANr4VX8LDWQ3kMj0yoqyqiwK3SEqtIXkA-22639ZQQ.cache +2 -0
  49. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/mKfHoait9-j98PxObraQnsOWSk7xeFfrgppKbFtsUP0.cache +1 -0
  50. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/s0L4Qc1LxOsV_VIoN33m851q4i5lQVM1ygIhke4UJhM.cache +2 -0
  51. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/sjZSTu90VegaTEOBnEbgI9A0_THfWp-_QVzTR7p7m_k.cache +1 -0
  52. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/y7TMQhIN-uRk0HFOYLmEtgTZdktzieFoy6OGzULuesI.cache +0 -0
  53. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/ysMIP1GiNEslwSMFx4V6kVDb4UFG1mgq0U7Pjh2AIzY.cache +1 -0
  54. data/spec/dummy/tmp/capybara/capybara-201508010214202383711168.html +19 -0
  55. data/spec/dummy/tmp/capybara/capybara-201508010214573127580777.html +1 -0
  56. data/spec/dummy/tmp/capybara/capybara-201508010215518845010832.html +16 -0
  57. data/spec/featrues/nyauth/sessions_spec.rb +12 -0
  58. data/spec/helpers/nyauth/application_helper_spec.rb +50 -50
  59. data/spec/lib/generators/nyauth/tmp/app/views/nyauth/confirmation_requests/new.html.erb +1 -1
  60. data/spec/lib/generators/nyauth/tmp/app/views/nyauth/passwords/edit.html.erb +1 -1
  61. data/spec/lib/generators/nyauth/tmp/app/views/nyauth/registrations/new.html.erb +1 -1
  62. data/spec/lib/generators/nyauth/tmp/app/views/nyauth/reset_password_requests/new.html.erb +1 -1
  63. data/spec/lib/generators/nyauth/tmp/app/views/nyauth/reset_passwords/edit.html.erb +1 -1
  64. data/spec/lib/generators/nyauth/tmp/app/views/nyauth/sessions/new.html.erb +1 -1
  65. data/spec/rails_helper.rb +1 -2
  66. metadata +64 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52716de1c677f6ce21afc860a01e77f344044698
4
- data.tar.gz: 356ea1bc8a34c7d72f0792794dcc01242fe9ecbd
3
+ metadata.gz: 87601c468486a44c289a5237814b284c2ddd99a3
4
+ data.tar.gz: 6a6b8354a185b0e79712b0ead1fb173a7277074c
5
5
  SHA512:
6
- metadata.gz: 579895bb751bcc14a30e191567d7a6c43ddad922dd89d7bc10c441841cbb6ad4364b192ee20b9c32f98742d4a82d3501731ac0e862d171db553209788324843d
7
- data.tar.gz: d421b721c37802b4a4299b835cc3888117ebcb0ec9d203066bf90fd2a4f62472eef5f6699c6dc4b73148227d6ae65ef68026e837f96c60472bdfe71d66547eb9
6
+ metadata.gz: faa4fe34f07107d34c8eec9afa935522bf28e29f5f78e60a391c4923a02009338b8398ebace396d42314535c21dd275f8aba592a5635d75bc6d9324760358c64
7
+ data.tar.gz: 35c441c44d9e59689368b606fe49267e68ffb4bd6fab19708901472faaf1d95a60bcb0d8199384c13ba33faa9930ec4532161643d11afe0ab3f7c9731f4abb2d
data/README.md CHANGED
@@ -8,8 +8,7 @@ Simple & modulable authentication gem
8
8
 
9
9
  ```ruby
10
10
  class ApplicationController < ActionController::Base
11
- include Nyauth::SessionConcern
12
- include Nyauth::ClientConcern
11
+ include Nyauth::ControllerConcern
13
12
  before_action -> { require_authentication! as: client_name }
14
13
  end
15
14
  ```
@@ -199,11 +198,16 @@ ja:
199
198
  spec/rails_helper.rb
200
199
 
201
200
  ```ruby
202
- require 'nyauth/test/controller_macros'
203
- require 'nyauth/test/feature_macros'
201
+ require 'nyauth/test/macros'
204
202
 
205
203
  RSpec.configure do |config|
206
204
  config.include Nyauth::Test::ControllerMacros, type: :controller
207
205
  config.include Nyauth::Test::FeatureMacros, type: :feature
208
206
  end
209
207
  ```
208
+
209
+ use macro
210
+
211
+ ```
212
+ background { sign_in(user) }
213
+ ```
@@ -2,30 +2,42 @@ module Nyauth
2
2
  module ClientConcern
3
3
  extend ActiveSupport::Concern
4
4
  included do |base|
5
- helper_method :client_class
6
- helper_method :client_name
5
+ helper_method :nyauth_client_class
6
+ helper_method :nyauth_client_name
7
+ helper_method :client_class # deprecated
8
+ helper_method :client_name # deprecated
7
9
  end
8
10
 
9
11
  def initialize
10
- @client_classes = {}
12
+ @nyauth_client_classes = {}
11
13
  super
12
14
  end
13
15
 
14
16
  private
15
17
 
16
- def mounted_path
18
+ def nyauth_mounted_path
17
19
  request.script_name.presence || "/#{request.path.split('/').try(:second)}"
18
20
  end
19
21
 
20
- # specify client class from mounted_path
21
- def client_class
22
- @client_classes[mounted_path] ||= mounted_path[1..-1].classify.constantize
22
+ # specify client class from nyauth_mounted_path
23
+ def nyauth_client_class
24
+ @nyauth_client_classes[nyauth_mounted_path] ||= nyauth_mounted_path[1..-1].classify.constantize
23
25
  rescue
24
- @client_classes[mounted_path] = User
26
+ @nyauth_client_classes[nyauth_mounted_path] = User
27
+ end
28
+
29
+ def nyauth_client_name
30
+ nyauth_client_class.name.underscore.to_sym
31
+ end
32
+
33
+ def client_class
34
+ warn 'DEPRECATION WARNING: client_class is deprecated. Please use nyauth_client_class'
35
+ nyauth_client_class
25
36
  end
26
37
 
27
38
  def client_name
28
- client_class.name.underscore.to_sym
39
+ warn 'DEPRECATION WARNING: client_name is deprecated. Please use nyauth_client_name'
40
+ nyauth_client_name
29
41
  end
30
42
  end
31
43
  end
@@ -1,7 +1,9 @@
1
1
  module Nyauth
2
- module ApplicationConcern
2
+ module ControllerConcern
3
3
  extend ActiveSupport::Concern
4
4
  include Nyauth::ApplicationHelper
5
+ include Nyauth::SessionConcern
6
+ include Nyauth::ClientConcern
5
7
 
6
8
  included do
7
9
  helper Nyauth::ApplicationHelper
@@ -36,7 +36,8 @@ module Nyauth
36
36
  options.reverse_merge!(as: :user)
37
37
  return if self.class.allow_actions == :all
38
38
  return if self.class.allow_actions.present? && request[:action].to_sym.in?(self.class.allow_actions)
39
- head :unauthorized unless signed_in?(options)
39
+ session["#{options[:as]}_return_to"] = request.url if request.get?
40
+ redirect_to new_session_path_for(options[:as]) unless signed_in?(options)
40
41
  end
41
42
 
42
43
  def current_authenticated(options = {})
@@ -1,7 +1,6 @@
1
1
  module Nyauth
2
2
  class ConfirmationRequestsController < ApplicationController
3
- include Nyauth::ApplicationConcern
4
- include Nyauth::ClientConcern
3
+ include Nyauth::ControllerConcern
5
4
  allow_everyone
6
5
  self.responder = Nyauth::AppResponder
7
6
  respond_to :html, :json
@@ -13,13 +12,13 @@ module Nyauth
13
12
 
14
13
  def create
15
14
  @client.request_confirmation
16
- respond_with(@client, location: Nyauth.configuration.redirect_path_after_create_request_confirmation.call(client_name) || main_app.root_path)
15
+ respond_with(@client, location: Nyauth.configuration.redirect_path_after_create_request_confirmation.call(nyauth_client_name) || main_app.root_path)
17
16
  end
18
17
 
19
18
  private
20
19
 
21
20
  def set_client
22
- @client = client_class.find_by!(email: params[client_name][:email])
21
+ @client = nyauth_client_class.find_by!(email: params[nyauth_client_name][:email])
23
22
  rescue ActiveRecord::RecordNotFound
24
23
  render :new
25
24
  end
@@ -1,7 +1,6 @@
1
1
  module Nyauth
2
2
  class ConfirmationsController < ApplicationController
3
- include Nyauth::ApplicationConcern
4
- include Nyauth::ClientConcern
3
+ include Nyauth::ControllerConcern
5
4
  allow_everyone
6
5
  self.responder = ConfirmationResponder
7
6
  respond_to :html, :json
@@ -9,13 +8,13 @@ module Nyauth
9
8
 
10
9
  def update
11
10
  @client.confirm
12
- respond_with(@client, location: Nyauth.configuration.redirect_path_after_update_confirmation.call(client_name) || main_app.root_path)
11
+ respond_with(@client, location: Nyauth.configuration.redirect_path_after_update_confirmation.call(nyauth_client_name) || main_app.root_path)
13
12
  end
14
13
 
15
14
  private
16
15
 
17
16
  def set_client
18
- @client = client_class.find_by!(confirmation_key: params[:confirmation_key])
17
+ @client = nyauth_client_class.find_by!(confirmation_key: params[:confirmation_key])
19
18
  end
20
19
  end
21
20
  end
@@ -1,9 +1,7 @@
1
1
  module Nyauth
2
2
  class PasswordsController < ApplicationController
3
- include Nyauth::ApplicationConcern
4
- include Nyauth::ClientConcern
5
- include Nyauth::SessionConcern
6
- before_action -> { require_authentication! as: client_name }
3
+ include Nyauth::ControllerConcern
4
+ before_action -> { require_authentication! as: nyauth_client_name }
7
5
 
8
6
  self.responder = Nyauth::AppResponder
9
7
  respond_to :html, :json
@@ -15,17 +13,17 @@ module Nyauth
15
13
  def update
16
14
  @client.attributes = client_params
17
15
  @client.save(context: :update_password)
18
- respond_with(@client, location: Nyauth.configuration.redirect_path_after_update_password.call(client_name) || main_app.root_path)
16
+ respond_with(@client, location: Nyauth.configuration.redirect_path_after_update_password.call(nyauth_client_name) || main_app.root_path)
19
17
  end
20
18
 
21
19
  private
22
20
 
23
21
  def set_client
24
- @client = client_class.find(current_authenticated.id)
22
+ @client = nyauth_client_class.find(current_authenticated.id)
25
23
  end
26
24
 
27
25
  def client_params
28
- params.fetch(client_name, {})
26
+ params.fetch(nyauth_client_name, {})
29
27
  .permit(:password, :password_confirmation)
30
28
  end
31
29
  end
@@ -1,7 +1,6 @@
1
1
  module Nyauth
2
2
  class RegistrationsController < ApplicationController
3
- include Nyauth::ApplicationConcern
4
- include Nyauth::ClientConcern
3
+ include Nyauth::ControllerConcern
5
4
  allow_everyone
6
5
  self.responder = Nyauth::AppResponder
7
6
  respond_to :html, :json
@@ -12,17 +11,17 @@ module Nyauth
12
11
 
13
12
  def create
14
13
  sign_in(@client) if @client.save
15
- respond_with(@client, location: Nyauth.configuration.redirect_path_after_registration.call(client_name) || main_app.root_path)
14
+ respond_with(@client, location: Nyauth.configuration.redirect_path_after_registration.call(nyauth_client_name) || main_app.root_path)
16
15
  end
17
16
 
18
17
  private
19
18
 
20
19
  def set_client
21
- @client = client_class.new(client_params)
20
+ @client = nyauth_client_class.new(client_params)
22
21
  end
23
22
 
24
23
  def client_params
25
- params.fetch(client_name, {})
24
+ params.fetch(nyauth_client_name, {})
26
25
  .permit(:email, :password, :password_confirmation)
27
26
  end
28
27
  end
@@ -1,7 +1,6 @@
1
1
  module Nyauth
2
2
  class ResetPasswordRequestsController < ApplicationController
3
- include Nyauth::ApplicationConcern
4
- include Nyauth::ClientConcern
3
+ include Nyauth::ControllerConcern
5
4
  allow_everyone
6
5
  self.responder = Nyauth::AppResponder
7
6
  respond_to :html, :json
@@ -13,13 +12,13 @@ module Nyauth
13
12
 
14
13
  def create
15
14
  @client.request_reset_password
16
- respond_with(@client, location: Nyauth.configuration.redirect_path_after_reset_password_request.call(client_name) || main_app.root_path)
15
+ respond_with(@client, location: Nyauth.configuration.redirect_path_after_reset_password_request.call(nyauth_client_name) || main_app.root_path)
17
16
  end
18
17
 
19
18
  private
20
19
 
21
20
  def set_client
22
- @client = client_class.find_by!(email: params[client_name][:email])
21
+ @client = nyauth_client_class.find_by!(email: params[nyauth_client_name][:email])
23
22
  rescue ActiveRecord::RecordNotFound
24
23
  render :new
25
24
  end
@@ -1,7 +1,6 @@
1
1
  module Nyauth
2
2
  class ResetPasswordsController < ApplicationController
3
- include Nyauth::ApplicationConcern
4
- include Nyauth::ClientConcern
3
+ include Nyauth::ControllerConcern
5
4
  allow_everyone
6
5
  self.responder = Nyauth::AppResponder
7
6
  respond_to :html, :json
@@ -9,23 +8,23 @@ module Nyauth
9
8
 
10
9
  def edit
11
10
  unless @client.valid?(:edit_reset_password)
12
- redirect_to new_session_path_for(client_name), alert: @client.errors[:reset_password_key].last
11
+ redirect_to new_session_path_for(nyauth_client_name), alert: @client.errors[:reset_password_key].last
13
12
  end
14
13
  end
15
14
 
16
15
  def update
17
16
  @client.reset_password(client_params)
18
- respond_with(@client, location: Nyauth.configuration.redirect_path_after_reset_password.call(client_name) || new_session_path_for(client_name))
17
+ respond_with(@client, location: Nyauth.configuration.redirect_path_after_reset_password.call(nyauth_client_name) || new_session_path_for(nyauth_client_name))
19
18
  end
20
19
 
21
20
  private
22
21
 
23
22
  def set_client
24
- @client = client_class.find_by!(reset_password_key: params[:reset_password_key])
23
+ @client = nyauth_client_class.find_by!(reset_password_key: params[:reset_password_key])
25
24
  end
26
25
 
27
26
  def client_params
28
- params.fetch(client_name, {})
27
+ params.fetch(nyauth_client_name, {})
29
28
  .permit(:password, :password_confirmation)
30
29
  end
31
30
  end
@@ -1,9 +1,7 @@
1
1
  module Nyauth
2
2
  class SessionsController < ApplicationController
3
- include Nyauth::ApplicationConcern
4
- include Nyauth::ClientConcern
5
- include Nyauth::SessionConcern
6
- before_action -> { require_authentication! as: client_name }
3
+ include Nyauth::ControllerConcern
4
+ before_action -> { require_authentication! as: nyauth_client_name }
7
5
  allow_everyone only: [:new, :create]
8
6
  self.responder = Nyauth::AppResponder
9
7
  respond_to :html, :json
@@ -13,13 +11,17 @@ module Nyauth
13
11
  end
14
12
 
15
13
  def create
16
- sign_in(@session_service.client) if @session_service.save(as: client_name)
17
- respond_with @session_service, location: Nyauth.configuration.redirect_path_after_sign_in.call(client_name) || main_app.root_path
14
+ sign_in(@session_service.client) if @session_service.save(as: nyauth_client_name)
15
+ redirect_path = session.delete("#{nyauth_client_name}_return_to")
16
+ respond_with @session_service,
17
+ location: redirect_path || \
18
+ Nyauth.configuration.redirect_path_after_sign_in.call(nyauth_client_name) || \
19
+ main_app.root_path
18
20
  end
19
21
 
20
22
  def destroy
21
23
  sign_out
22
- respond_with @session_service, location: Nyauth.configuration.redirect_path_after_sign_out.call(client_name) || new_session_path_for(client_name)
24
+ respond_with @session_service, location: Nyauth.configuration.redirect_path_after_sign_out.call(nyauth_client_name) || new_session_path_for(nyauth_client_name)
23
25
  end
24
26
 
25
27
  private
@@ -11,14 +11,14 @@ module Nyauth
11
11
  end
12
12
 
13
13
  # OPTIMEZE: :(
14
- def detect_url_helper(feature, client_name, *args)
14
+ def detect_url_helper(feature, nyauth_client_name, *args)
15
15
  @__methods ||= Nyauth::Engine.routes.url_helpers.instance_methods + Rails.application.routes.url_helpers.instance_methods
16
16
  @__candidates ||= @__methods.reject{|m| m =~ /\A(:?rails_|_)/}.map(&:to_s)
17
- if respond_to?(:nyauth) && client_name.to_sym == :user
17
+ if respond_to?(:nyauth) && nyauth_client_name.to_sym == :user
18
18
  # mounted as nyauth
19
19
  detect_url_helper_for_nyauth(feature, *args)
20
20
  else
21
- detect_url_helper_for_app(feature, client_name, *args)
21
+ detect_url_helper_for_app(feature, nyauth_client_name, *args)
22
22
  end
23
23
  end
24
24
 
@@ -28,11 +28,11 @@ module Nyauth
28
28
  nyauth.__send__(path, *args)
29
29
  end
30
30
 
31
- def detect_url_helper_for_app(feature, client_name, *args)
31
+ def detect_url_helper_for_app(feature, nyauth_client_name, *args)
32
32
  if feature =~ /new_(.+)/
33
- path = @__candidates.grep(/\Anew_#{client_name}_#{$1}_path\z/).first
33
+ path = @__candidates.grep(/\Anew_#{nyauth_client_name}_#{$1}_path\z/).first
34
34
  else
35
- path = @__candidates.grep(/\A#{client_name}_#{feature}_path\z/).first
35
+ path = @__candidates.grep(/\A#{nyauth_client_name}_#{feature}_path\z/).first
36
36
  end
37
37
  return nil unless path
38
38
  main_app.__send__(path, *args)
@@ -1,4 +1,4 @@
1
- <%= form_for client_class.new, url: confirmation_requests_path_for(client_name) do |f| %>
1
+ <%= form_for nyauth_client_class.new, url: confirmation_requests_path_for(nyauth_client_name) do |f| %>
2
2
  <%= f.email_field :email %>
3
3
  <%= f.submit 'request confirmation' %>
4
4
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= form_for @client, url: password_path_for(client_name) do |f| %>
1
+ <%= form_for @client, url: password_path_for(nyauth_client_name) do |f| %>
2
2
  <%= f.object.errors.full_messages %>
3
3
  <%= f.password_field :password %>
4
4
  <%= f.password_field :password_confirmation %>
@@ -1,4 +1,4 @@
1
- <%= form_for @client, url: registration_path_for(client_name) do |f| %>
1
+ <%= form_for @client, url: registration_path_for(nyauth_client_name) do |f| %>
2
2
  <%= f.object.errors.full_messages.join ',' %>
3
3
  <%= f.email_field :email %>
4
4
  <%= f.password_field :password %>
@@ -1,4 +1,4 @@
1
- <%= form_for client_class.new, url: reset_password_requests_path_for(client_name) do |f| %>
1
+ <%= form_for nyauth_client_class.new, url: reset_password_requests_path_for(nyauth_client_name) do |f| %>
2
2
  <%= f.text_field :email %>
3
3
  <%= f.submit 'reset password' %>
4
4
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= form_for @client, url: reset_password_path_for(client_name, params[:reset_password_key]) do |f| %>
1
+ <%= form_for @client, url: reset_password_path_for(nyauth_client_name, params[:reset_password_key]) do |f| %>
2
2
  <%= f.object.errors.full_messages %>
3
3
  <%= f.password_field :password %>
4
4
  <%= f.password_field :password_confirmation %>
@@ -1,4 +1,4 @@
1
- <%= form_for @session_service, url: session_path_for(client_name) do |f| %>
1
+ <%= form_for @session_service, url: session_path_for(nyauth_client_name) do |f| %>
2
2
  <%= f.object.errors.full_messages.join ',' %>
3
3
  <%= f.email_field :email %>
4
4
  <%= f.password_field :password %>
@@ -0,0 +1,2 @@
1
+ require 'nyauth/test/controller_macros'
2
+ require 'nyauth/test/feature_macros'
@@ -1,3 +1,3 @@
1
1
  module Nyauth
2
- VERSION = "0.2.8"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,8 +1,4 @@
1
1
  class ApplicationController < ActionController::Base
2
- include Nyauth::ApplicationConcern
3
- include Nyauth::SessionConcern
4
- self.responder = Nyauth::AppResponder
5
- # Prevent CSRF attacks by raising an exception.
6
- # For APIs, you may want to use :null_session instead.
2
+ include Nyauth::ControllerConcern
7
3
  protect_from_forgery with: :exception
8
4
  end
@@ -1,5 +1,6 @@
1
1
  class PostsController < ApplicationController
2
+ before_action -> { require_authentication! as: :user }
3
+
2
4
  def index
3
- head :ok
4
5
  end
5
6
  end
File without changes
Binary file