spree_auth_devise 4.1.0.rc1 → 4.3.2

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 spree_auth_devise might be problematic. Click here for more details.

Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +32 -23
  3. data/Appraisals +1 -1
  4. data/README.md +3 -12
  5. data/Rakefile +9 -3
  6. data/app/controllers/spree/api/v2/storefront/account_confirmations_controller.rb +20 -0
  7. data/app/controllers/spree/api/v2/storefront/passwords_controller.rb +35 -0
  8. data/app/controllers/spree/user_confirmations_controller.rb +45 -1
  9. data/app/controllers/spree/user_passwords_controller.rb +15 -1
  10. data/app/controllers/spree/user_registrations_controller.rb +33 -1
  11. data/app/controllers/spree/user_sessions_controller.rb +8 -0
  12. data/app/mailers/spree/user_mailer.rb +11 -4
  13. data/app/models/spree/user.rb +42 -0
  14. data/app/services/spree/account/create.rb +19 -0
  15. data/app/services/spree/account/update.rb +17 -0
  16. data/app/views/spree/user_mailer/confirmation_instructions.html.erb +20 -0
  17. data/app/views/spree/user_mailer/confirmation_instructions.text.erb +8 -5
  18. data/app/views/spree/user_mailer/reset_password_instructions.html.erb +20 -0
  19. data/app/views/spree/user_mailer/reset_password_instructions.text.erb +7 -5
  20. data/app/views/spree/user_passwords/new.html.erb +2 -3
  21. data/config/locales/de.yml +16 -0
  22. data/config/locales/en.yml +21 -6
  23. data/config/locales/zh-TW.yml +58 -0
  24. data/config/routes.rb +12 -2
  25. data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +2 -2
  26. data/gemfiles/spree_4_1.gemfile +1 -1
  27. data/lib/controllers/api/spree/api/v2/storefront/account_controller_decorator.rb +41 -0
  28. data/lib/controllers/frontend/spree/checkout_controller_decorator.rb +3 -2
  29. data/lib/controllers/frontend/spree/users_controller.rb +3 -3
  30. data/lib/spree/auth/engine.rb +14 -1
  31. data/lib/spree_auth_devise.rb +0 -1
  32. data/lib/views/backend/spree/admin/user_passwords/new.html.erb +1 -1
  33. data/lib/views/backend/spree/admin/user_sessions/new.html.erb +1 -1
  34. data/spec/controllers/spree/api/v2/storefront/passwords_controller_spec.rb +63 -0
  35. data/spec/controllers/spree/user_registrations_controller_spec.rb +1 -1
  36. data/spec/features/admin/sign_in_spec.rb +8 -2
  37. data/spec/features/checkout_spec.rb +4 -4
  38. data/spec/features/confirmation_spec.rb +3 -3
  39. data/spec/features/sign_in_spec.rb +13 -7
  40. data/spec/features/sign_out_spec.rb +1 -3
  41. data/spec/features/sign_up_spec.rb +2 -2
  42. data/spec/mailers/user_mailer_spec.rb +3 -3
  43. data/spec/models/user_spec.rb +10 -8
  44. data/spec/requests/spree/api/v2/storefront/account_confirmation_spec.rb +48 -0
  45. data/spec/requests/spree/api/v2/storefront/account_spec.rb +101 -0
  46. data/spec/spec_helper.rb +7 -38
  47. data/spree_auth_devise.gemspec +12 -29
  48. metadata +29 -359
  49. data/app/overrides/spree/admin/shared/_header/auth_admin_login_navigation_bar.html.erb.deface +0 -4
  50. data/spec/support/add_to_cart.rb +0 -22
  51. data/spec/support/authentication_helpers.rb +0 -14
  52. data/spec/support/cache_helpers.rb +0 -5
  53. data/spec/support/capybara.rb +0 -23
  54. data/spec/support/database_cleaner.rb +0 -17
  55. data/spec/support/factory_girl.rb +0 -5
  56. data/spec/support/spree.rb +0 -10
@@ -0,0 +1,19 @@
1
+ module Spree
2
+ module Account
3
+ class Create
4
+ prepend Spree::ServiceModule::Base
5
+
6
+ def call(user_params: nil)
7
+ user_params ||= {}
8
+
9
+ user = Spree.user_class.new(user_params)
10
+
11
+ if user.save
12
+ success(user)
13
+ else
14
+ failure(user)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ module Spree
2
+ module Account
3
+ class Update
4
+ prepend Spree::ServiceModule::Base
5
+
6
+ def call(user:, user_params: nil)
7
+ user_params ||= {}
8
+
9
+ if user.update(user_params)
10
+ success(user)
11
+ else
12
+ failure(user)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ <h1>
2
+ <%= Spree.t('user_mailer.confirmation_instructions.welcome', email: @email) %>
3
+ </h1>
4
+ <p>
5
+ <%= Spree.t('user_mailer.confirmation_instructions.instructions_1', { store_name: @current_store.name }) %>
6
+ </p>
7
+ <p>
8
+ <%= Spree.t('user_mailer.confirmation_instructions.instructions_2') %>
9
+ </p>
10
+ <p class="body-action">
11
+ <a href="<%= @confirmation_url %>" class="button button--green"><%= Spree.t('user_mailer.confirmation_instructions.button') %></a>
12
+ </p>
13
+ <p>
14
+ <%= Spree.t('user_mailer.confirmation_instructions.instructions_3') %>
15
+ </p>
16
+ <p>
17
+ <%= Spree.t('user_mailer.confirmation_instructions.thanks') %>
18
+ <br />
19
+ <%= Spree.t('user_mailer.confirmation_instructions.store_team', { store_name: @current_store.name }) %>
20
+ </p>
@@ -1,5 +1,8 @@
1
- Welcome <%= @email %>!
2
-
3
- You can confirm your account email through the url below:
4
-
5
- <%= @confirmation_url %>
1
+ <%= Spree.t('user_mailer.confirmation_instructions.welcome', email: @email) %>
2
+ <%= Spree.t('user_mailer.confirmation_instructions.instructions_1', { store_name: @current_store.name }) %>
3
+ <%= Spree.t('user_mailer.confirmation_instructions.instructions_2') %>
4
+ <%= Spree.t('user_mailer.confirmation_instructions.button') %>
5
+ <%= @confirmation_url %>
6
+ <%= Spree.t('user_mailer.confirmation_instructions.instructions_3') %>
7
+ <%= Spree.t('user_mailer.confirmation_instructions.thanks') %>
8
+ <%= Spree.t('user_mailer.confirmation_instructions.store_team', { store_name: @current_store.name }) %>
@@ -0,0 +1,20 @@
1
+ <h1>
2
+ <%= Spree.t('user_mailer.reset_password_instructions.welcome', email: @user.email) %>
3
+ </h1>
4
+ <p>
5
+ <%= Spree.t('user_mailer.reset_password_instructions.instructions_1', { store_name: @current_store.name }) %>
6
+ </p>
7
+ <p>
8
+ <%= Spree.t('user_mailer.reset_password_instructions.instructions_2') %>
9
+ </p>
10
+ <p class="body-action">
11
+ <a href="<%= @edit_password_reset_url %>" class="button button--green"><%= Spree.t('user_mailer.reset_password_instructions.button') %></a>
12
+ </p>
13
+ <p>
14
+ <%= Spree.t('user_mailer.reset_password_instructions.instructions_3') %>
15
+ </p>
16
+ <p>
17
+ <%= Spree.t('user_mailer.reset_password_instructions.thanks') %>
18
+ <br />
19
+ <%= Spree.t('user_mailer.reset_password_instructions.store_team', { store_name: @current_store.name }) %>
20
+ </p>
@@ -1,10 +1,12 @@
1
- A request to reset your password has been made.
2
- If you did not make this request, simply ignore this email.
1
+ <%= Spree.t('user_mailer.reset_password_instructions.welcome', email: @user.email) %>
3
2
 
4
- If you did make this request just click the link below:
3
+ <%= Spree.t('user_mailer.reset_password_instructions.instructions_1', { store_name: @current_store.name }) %>
4
+ <%= Spree.t('user_mailer.reset_password_instructions.instructions_2') %>
5
5
 
6
+ <%= Spree.t('user_mailer.reset_password_instructions.button') %>
6
7
  <%= @edit_password_reset_url %>
7
8
 
8
- If the above URL does not work try copying and pasting it into your browser.
9
- If you continue to have problems please feel free to contact us.
9
+ <%= Spree.t('user_mailer.reset_password_instructions.instructions_3') %>
10
10
 
11
+ <%= Spree.t('user_mailer.reset_password_instructions.thanks') %>
12
+ <%= Spree.t('user_mailer.reset_password_instructions.store_team', { store_name: @current_store.name }) %>
@@ -8,10 +8,9 @@
8
8
  <div class="card-body">
9
9
  <p><%= Spree.t(:instructions_to_reset_password) %></p>
10
10
 
11
- <%= form_for Spree::User.new, as: :spree_user, url: spree.reset_password_path do |f| %>
11
+ <%= form_for Spree.user_class.new, as: :spree_user, url: spree.reset_password_path do |f| %>
12
12
  <div class="form-group">
13
- <%= f.label :email, Spree.t(:email), class: 'spree-flat-label' %>
14
- <%= f.email_field :email, class: "spree-flat-input" %>
13
+ <%= f.email_field :email, class: "spree-flat-input", placeholder: Spree.t(:email) %>
15
14
  </div>
16
15
  <div>
17
16
  <%= f.submit Spree.t(:reset_password), class: 'btn btn-primary btn-block spree-btn mt-2' %>
@@ -1,9 +1,21 @@
1
1
  ---
2
2
  de:
3
+ spree:
4
+ admin_login: Admin Login
5
+ change_your_password: Kennwort zurücksetzen
6
+ user_mailer:
7
+ reset_password_instructions:
8
+ instructions_1: "Es wurde eine Anfrage zum Zurücksetzen Ihres Passworts gestellt.\nWenn Sie diese Anfrage nicht gestellt haben, ignorieren Sie diese E-Mail.\n\nWenn Sie diese Anfrage gestellt haben, klicken Sie bitte auf den folgenden Link:"
9
+ instructions_2: "Falls die obige URL nicht funktioniert, bitte URL kopieren und in Ihren Browser einfügen\nWenn Sie weiterhin Probleme haben, können Sie sich gerne an uns wenden."
10
+ confirmation_instructions:
11
+ welcome: "Schön, dass Sie hier sind %{email}"
12
+ confirm: "Sie können Ihre Konto-E-Mail-Adresse über die folgende URL bestätigen:"
3
13
  devise:
4
14
  confirmations:
5
15
  confirmed: Ihr Konto wurde erfolgreich aktiviert.
6
16
  send_instructions: 'In ein paar Minuten erhalten Sie eine E-Mail mit Anweisungen, um Ihr Konto zu aktivieren.'
17
+ spree_user:
18
+ already_confirmed: Ihre E-Mail wurde bereits bestätigt. Bitte versuchen Sie erneut, sich anzumelden.
7
19
  failure:
8
20
  inactive: Ihr Konto wurde noch nicht aktiviert.
9
21
  invalid: Ungültige E-Mail-Adresse oder Passwort.
@@ -28,16 +40,20 @@ de:
28
40
  user_passwords:
29
41
  spree_user:
30
42
  cannot_be_blank: Ihr Passwort darf nicht leer sein.
43
+ no_token: Sie können nicht auf diese Seite zugreifen, wenn Sie den Link aus einer E-Mail zum Zurücksetzen des Kennworts nicht verwenden. Wenn Sie den Link aus einer E-Mail zum Zurücksetzen des Passworts verwenden, stellen Sie bitte sicher, dass Sie die vollständige URL verwendet haben.
31
44
  send_instructions: In ein paar Minuten erhalten Sie eine E-Mail mit Anweisungen um Ihr Passwort zurücksetzen.
32
45
  updated: Ihr Passwort wurde erfolgreich geändert.
33
46
  user_registrations:
34
47
  destroyed: Ihr Konto wurde erfolgreich gelöscht. Auf Wiedersehen!
35
48
  inactive_signed_up: 'Sie haben sich erfolgreich registriert. Wir konnten Sie jedoch nicht anmelden, da Ihr Konto %{reason} ist.'
49
+ signed_up_but_unconfirmed: Eine Nachricht mit einem Bestätigungslink wurde an Ihre E-Mail-Adresse gesendet. Bitte folgen Sie dem Link, um Ihr Konto zu aktivieren.
36
50
  signed_up: Herzlich Willkommen! Sie haben sich erfolgreich registriert.
37
51
  updated: Sie haben Ihr Konto erfolgreich aktualisiert.
38
52
  user_sessions:
39
53
  signed_in: Erfolgreich angemeldet.
40
54
  signed_out: Erfolgreich abgemeldet.
55
+ already_signed_in: Bereits angemeldet.
56
+ already_signed_out: Bereits abgemeldet.
41
57
  errors:
42
58
  messages:
43
59
  already_confirmed: wurde bereits bestätigt
@@ -3,12 +3,29 @@ en:
3
3
  spree:
4
4
  admin_login: "Admin Login"
5
5
  change_your_password: "Change your password"
6
- store_credits:
7
- credit_balance: Store Credit Balance
6
+ user_mailer:
7
+ reset_password_instructions:
8
+ welcome: "Hi %{email}"
9
+ instructions_1: "A request to reset the password for your %{store_name} account has been made."
10
+ instructions_2: Click the button below to reset it.
11
+ instructions_3: If you did not request a password change ignore this email or contact us.
12
+ button: Reset your password
13
+ thanks: Thank you,
14
+ store_team: "%{store_name} Team"
15
+ confirmation_instructions:
16
+ welcome: "Welcome %{email}!"
17
+ instructions_1: "Thanks for registering at %{store_name}."
18
+ instructions_2: "Click the button below to confirm your account:"
19
+ instructions_3: If you have any questions, feel free to simply reply to this email.
20
+ button: Confirm email address
21
+ thanks: Thank you,
22
+ store_team: "%{store_name} Team"
8
23
  devise:
9
24
  confirmations:
10
- confirmed: Your account was successfully confirmed. You are now signed in.
25
+ confirmed: Your account was successfully confirmed. You can now log in.
11
26
  send_instructions: You will receive an email with instructions about how to confirm your account in a few minutes.
27
+ spree_user:
28
+ already_confirmed: Email was already confirmed, please try signing in.
12
29
  failure:
13
30
  inactive: Your account was not activated yet.
14
31
  invalid: Invalid email or password.
@@ -24,8 +41,6 @@ en:
24
41
  subject: Reset password instructions
25
42
  unlock_instructions:
26
43
  subject: Unlock Instructions
27
- confirmation_instructions:
28
- subject: Confirmation instructions
29
44
  oauth_callbacks:
30
45
  failure: 'Could not authorize you from %{kind} because %{reason}.'
31
46
  success: 'Successfully authorized from %{kind} account.'
@@ -41,7 +56,7 @@ en:
41
56
  user_registrations:
42
57
  destroyed: Bye! Your account was successfully cancelled. We hope to see you again soon.
43
58
  inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
44
- signed_up_but_unconfirmed: You have signed up successfully.
59
+ signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
45
60
  signed_up: Welcome! You have signed up successfully.
46
61
  updated: You updated your account successfully.
47
62
  user_sessions:
@@ -0,0 +1,58 @@
1
+ ---
2
+ zh-TW:
3
+ spree:
4
+ admin_login: "管理員登入"
5
+ change_your_password: "更改密碼"
6
+ devise:
7
+ confirmations:
8
+ confirmed: 你的帳號已經確認完成,現在你已經登入網站了。
9
+ send_instructions: 你會在幾分鐘內收到一封帳號確認信來確認你的帳號。
10
+ spree_user:
11
+ already_confirmed: Email 已確認,請登入。
12
+ failure:
13
+ inactive: 你的帳號尚未啟用。
14
+ invalid: 帳號或密碼有誤。
15
+ invalid_token: 錯誤的認證代碼。
16
+ locked: 你的帳號已經被停權,請聯絡客服人員。
17
+ timeout: 你的登入已經逾時,請重新登入。
18
+ unauthenticated: 你需要登入來繼續。
19
+ unconfirmed: 你的帳號需要確認來繼續。
20
+ mailer:
21
+ confirmation_instructions:
22
+ subject: 帳號確認教學
23
+ reset_password_instructions:
24
+ subject: 重設密碼教學
25
+ unlock_instructions:
26
+ subject: 帳號解鎖教學
27
+ oauth_callbacks:
28
+ failure: '由於%{reason},無法透過%{kind}確認你的帳號。'
29
+ success: '成功的由%{kind}認證你的帳號。'
30
+ unlocks:
31
+ send_instructions: 你在幾分鐘後會收到一封 Email 教你如何解鎖帳號。
32
+ unlocked: 你的帳號已經解鎖,現在你已經登入網站了。
33
+ user_passwords:
34
+ spree_user:
35
+ cannot_be_blank: 密碼不能為空白。
36
+ no_token: "你只能透過重新設定密碼的 Email 內的連結來訪問此頁面。如果你真的是透過那封 Email 來此頁面,請確定你是透過完整的網址過來的。"
37
+ send_instructions: 你在幾分鐘後會收到一封 Email 教你如何更改密碼。
38
+ updated: 你的密碼已經更改成功,你已成功登入。
39
+ user_registrations:
40
+ destroyed: 再見!你的帳號已經被取消了,但我們希望能再服務你。
41
+ inactive_signed_up: '你已經成功註冊,但由於%{reason}的原因,導致帳號無法登入。'
42
+ signed_up_but_unconfirmed: 確認信件已經寄到您的信箱,請按照上面的教學完成您的註冊。
43
+ signed_up: 歡迎!你已經成功註冊了。
44
+ updated: 你的帳號已經成功更新。
45
+ user_sessions:
46
+ signed_in: 登入成功
47
+ signed_out: 登出成功
48
+ already_signed_in: 已經登入
49
+ already_signed_out: 已經登入
50
+ errors:
51
+ messages:
52
+ already_confirmed: 已確認
53
+ email_is_invalid: Email 不能為空值
54
+ not_found: 找不到
55
+ not_locked: 沒有被鎖住
56
+ not_saved:
57
+ one: '%{resource}由於以下的一個錯誤導致無法被儲存:'
58
+ other: '%{resource}由於以下的%{count}個錯誤導致無法被儲存:'
@@ -1,6 +1,6 @@
1
1
  Spree::Core::Engine.add_routes do
2
2
  devise_for :spree_user,
3
- class_name: 'Spree::User',
3
+ class_name: Spree.user_class.to_s,
4
4
  controllers: { sessions: 'spree/user_sessions',
5
5
  registrations: 'spree/user_registrations',
6
6
  passwords: 'spree/user_passwords',
@@ -31,7 +31,7 @@ Spree::Core::Engine.add_routes do
31
31
 
32
32
  namespace :admin, path: Spree.admin_path do
33
33
  devise_for :spree_user,
34
- class_name: 'Spree::User',
34
+ class_name: Spree.user_class.to_s,
35
35
  controllers: { sessions: 'spree/admin/user_sessions',
36
36
  passwords: 'spree/admin/user_passwords' },
37
37
  skip: [:unlocks, :omniauth_callbacks, :registrations],
@@ -44,4 +44,14 @@ Spree::Core::Engine.add_routes do
44
44
  get '/logout' => 'user_sessions#destroy', :as => :logout
45
45
  end
46
46
  end
47
+
48
+ namespace :api, defaults: { format: 'json' } do
49
+ namespace :v2 do
50
+ namespace :storefront do
51
+ resource :account, controller: :account, only: %i[show create update]
52
+ resources :account_confirmations, only: %i[show]
53
+ resources :passwords, controller: :passwords, only: %i[create update]
54
+ end
55
+ end
56
+ end
47
57
  end
@@ -1,7 +1,7 @@
1
1
  class AddResetPasswordSentAtToSpreeUsers < SpreeExtension::Migration[4.2]
2
2
  def change
3
- Spree::User.reset_column_information
4
- unless Spree::User.column_names.include?("reset_password_sent_at")
3
+ Spree.user_class.reset_column_information
4
+ unless Spree.user_class.column_names.include?("reset_password_sent_at")
5
5
  add_column :spree_users, :reset_password_sent_at, :datetime
6
6
  end
7
7
  end
@@ -3,6 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails-controller-testing"
6
- gem "spree", github: "spree/spree", branch: "master"
6
+ gem "spree", "~> 4.1"
7
7
 
8
8
  gemspec path: "../"
@@ -0,0 +1,41 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ module Storefront
5
+ module AccountControllerDecorator
6
+ def self.prepended(base)
7
+ base.skip_before_action :require_spree_current_user, only: [:create]
8
+ end
9
+
10
+ def create
11
+ result = Spree::Account::Create.call(user_params: spree_user_params)
12
+
13
+ render_payload(result)
14
+ end
15
+
16
+ def update
17
+ result = Spree::Account::Update.call(user: spree_current_user, user_params: spree_user_params)
18
+
19
+ render_payload(result)
20
+ end
21
+
22
+ private
23
+
24
+ def render_payload(result)
25
+ if result.success?
26
+ render_serialized_payload { serialize_resource(result.value) }
27
+ else
28
+ render_error_payload(result.error)
29
+ end
30
+ end
31
+
32
+ def spree_user_params
33
+ params.require(:user).permit(Spree::PermittedAttributes.user_attributes)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ ::Spree::Api::V2::Storefront::AccountController.prepend(Spree::Api::V2::Storefront::AccountControllerDecorator)
@@ -6,7 +6,8 @@ module Spree::CheckoutControllerDecorator
6
6
  end
7
7
 
8
8
  def registration
9
- @user = Spree::User.new
9
+ @user = Spree.user_class.new
10
+ @title = Spree.t(:registration)
10
11
  end
11
12
 
12
13
  def update_registration
@@ -14,7 +15,7 @@ module Spree::CheckoutControllerDecorator
14
15
  redirect_to spree.checkout_state_path(:address)
15
16
  else
16
17
  flash[:error] = t(:email_is_invalid, scope: [:errors, :messages])
17
- @user = Spree::User.new
18
+ @user = Spree.user_class.new
18
19
  render 'registration'
19
20
  end
20
21
  end
@@ -10,7 +10,7 @@ class Spree::UsersController < Spree::StoreController
10
10
  end
11
11
 
12
12
  def create
13
- @user = Spree::User.new(user_params)
13
+ @user = Spree.user_class.new(user_params)
14
14
  if @user.save
15
15
 
16
16
  if current_order
@@ -27,7 +27,7 @@ class Spree::UsersController < Spree::StoreController
27
27
  if @user.update(user_params)
28
28
  if params[:user][:password].present?
29
29
  # this logic needed b/c devise wants to log us out after password changes
30
- Spree::User.reset_password_by_token(params[:user])
30
+ Spree.user_class.reset_password_by_token(params[:user])
31
31
  if Spree::Auth::Config[:signout_after_password_change]
32
32
  sign_in(@user, event: :authentication)
33
33
  else
@@ -52,7 +52,7 @@ class Spree::UsersController < Spree::StoreController
52
52
  end
53
53
 
54
54
  def authorize_actions
55
- authorize! params[:action].to_sym, Spree::User.new
55
+ authorize! params[:action].to_sym, Spree.user_class.new
56
56
  end
57
57
 
58
58
  def accurate_title
@@ -42,7 +42,12 @@ module Spree
42
42
  'lib/assets/javascripts/spree/frontend/spree_auth.js',
43
43
  'lib/assets/javascripts/spree/frontend/spree_auth.css'
44
44
  ]
45
- Dir.glob(File.join(File.dirname(__FILE__), "../../controllers/frontend/*/*_decorator*.rb")) do |c|
45
+ Dir.glob(File.join(File.dirname(__FILE__), "../../controllers/frontend/**/*_decorator*.rb")) do |c|
46
+ Rails.configuration.cache_classes ? require(c) : load(c)
47
+ end
48
+ end
49
+ if Spree::Auth::Engine.api_available?
50
+ Dir.glob(File.join(File.dirname(__FILE__), "../../controllers/api/**/*_decorator*.rb")) do |c|
46
51
  Rails.configuration.cache_classes ? require(c) : load(c)
47
52
  end
48
53
  end
@@ -61,6 +66,10 @@ module Spree
61
66
  @@frontend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Frontend::Engine')
62
67
  end
63
68
 
69
+ def self.api_available?
70
+ @@api_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Api::Engine')
71
+ end
72
+
64
73
  if backend_available?
65
74
  paths["app/controllers"] << "lib/controllers/backend"
66
75
  paths["app/views"] << "lib/views/backend"
@@ -71,6 +80,10 @@ module Spree
71
80
  paths["app/views"] << "lib/views/frontend"
72
81
  end
73
82
 
83
+ if api_available?
84
+ paths["app/controllers"] << "lib/controllers/api"
85
+ end
86
+
74
87
  config.to_prepare &method(:activate).to_proc
75
88
  end
76
89
  end