0

I'm StackOverFlow newcomer. Nice to meet you.

Now, I'm making EC Rails App with Spree Framework.

Spree admin role user is all fine.

But custom role user redirect to authentication_failure after modifying source code in TextEditor.

Process occur error is following:

  1. Create custom user role colled 'sub_admin'.
  2. Create user has 'sub_admin' role;
  3. Log in with user has 'sub_admin' role;
  4. Has no problem first time. It seems that all is fine.
  5. Add code in model or controller file.(ex: add method, or change bit code)
  6. Save code with ⌘+s on Editor.
  7. Reload web page, recieve CanCan::AccessDenied and redirect to authentication_failure path.
  8. Reboot rais server
  9. Has no problem first time. It seems that all is fine.
  10. 3~9 loop endless...

Admin role has no problem every time. Problem Only Occurs in custom role. Error that come is -

CanCan::AccessDenied error.

What's the matter?
I read documentation and Gem code, but I cannot get no idea or hint.

My ability file is following:
sub_admin_ability.rb

module Spree
  class SubAdminAbility
    include CanCan::Ability

    def initialize(user)
      user ||= Spree.user_class.new

      if user.sub_admin?
        can [:admin, :manage], Spree::Product
        can [:admin, :manage], Spree::Address
        can [:admin, :manage], Spree::Profile
        can [:admin, :manage], Spree::Image
        can [:admin, :create, :update, :addresses], Spree::User
      end
    end
  end
end

I use Gem version:

  • spree 3.3.0
  • spree_auth_devise 3.3.1
  • spree_gateway 3.3.0

Thank you!

*add sign_out logs

Started GET "/logout" for xxx.xx.xx.xx at 2019-02-20 15:01:43 +0900
Cannot render console from xxx.xx.xx.xx! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Spree::UserSessionsController#destroy as HTML
  Spree::User Load (0.6ms)  SELECT  "spree_users".* FROM "spree_users" WHERE "spree_users"."deleted_at" IS NULL AND "spree_users"."id" = $1 ORDER BY "spree_users"."id" ASC LIMIT $2  [["id", 1], ["LIMIT", 1]]
  Spree::Preference Load (0.4ms)  SELECT  "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = $1 LIMIT $2  [["key", "spree/app_configuration/currency"], ["LIMIT", 1]]
  Spree::Store Load (0.5ms)  SELECT  "spree_stores".* FROM "spree_stores" WHERE (url like '%localhost%') ORDER BY "spree_stores"."id" ASC LIMIT $1  [["LIMIT", 1]]
  Spree::Order Load (0.6ms)  SELECT  "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."completed_at" IS NULL AND "spree_orders"."currency" = $1 AND "spree_orders"."guest_token" = $2 AND "spree_orders"."store_id" = $3 LIMIT $4  [["currency", "JPY"], ["guest_token", "dAvpS_lrpvdlbOxY2W6_RA1550053840935"], ["store_id", 1], ["LIMIT", 1]]
  Spree::Order Load (0.6ms)  SELECT  "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."user_id" = $1 AND "spree_orders"."completed_at" IS NULL ORDER BY created_at DESC LIMIT $2  [["user_id", 1], ["LIMIT", 1]]
  Spree::LineItem Load (0.5ms)  SELECT "spree_line_items".* FROM "spree_line_items" WHERE "spree_line_items"."order_id" = 27 ORDER BY "spree_line_items"."created_at" ASC
  Spree::Variant Load (0.5ms)  SELECT "spree_variants".* FROM "spree_variants" WHERE "spree_variants"."deleted_at" IS NULL AND "spree_variants"."id" = 8
  Spree::Image Load (0.5ms)  SELECT "spree_assets".* FROM "spree_assets" WHERE "spree_assets"."type" IN ('Spree::Image') AND "spree_assets"."viewable_type" = $1 AND "spree_assets"."viewable_id" = 8 ORDER BY "spree_assets"."position" ASC  [["viewable_type", "Spree::Variant"]]
  Spree::OptionValueVariant Load (0.4ms)  SELECT "spree_option_value_variants".* FROM "spree_option_value_variants" WHERE "spree_option_value_variants"."variant_id" = 8
  Spree::OptionValue Load (0.4ms)  SELECT "spree_option_values".* FROM "spree_option_values" WHERE "spree_option_values"."id" = 2
  Spree::Product Load (0.7ms)  SELECT "spree_products".* FROM "spree_products" WHERE "spree_products"."deleted_at" IS NULL AND "spree_products"."id" = 5
  Spree::Order Load (0.6ms)  SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."user_id" = $1 AND "spree_orders"."completed_at" IS NULL AND (id != 27)  [["user_id", 1]]
   (0.3ms)  BEGIN
   (0.3ms)  COMMIT
Redirected to http://localhost:3000/
Completed 302 Found in 36ms (ActiveRecord: 6.9ms)

0 Answers0