I have added name, surname and birthdate fields to devise registration. Here is the link to my original question.
Adding name to Spree Devise registration
It seems that on the frontend side everything works. However I now get an Authorization Failure alert when I try to access my admin.
Here is the console log:
Started GET "/admin/orders" for ::1 at 2015-07-21 13:25:16 -0500
Processing by Spree::Admin::OrdersController#index as HTML
Spree::Preference Load (0.3ms) SELECT "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = $1 LIMIT 1 [["key", "spree/backend_configuration/locale"]]
Spree::User Load (0.5ms) 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 1 [["id", 6]]
(0.7ms) SELECT COUNT(*) FROM "spree_roles" INNER JOIN "spree_roles_users" ON "spree_roles"."id" = "spree_roles_users"."role_id" WHERE "spree_roles_users"."user_id" = $1 AND "spree_roles"."name" = $2 [["user_id", 6], ["name", "admin"]]
Redirected to http://localhost:3000/unauthorized
Completed 302 Found in 88ms (ActiveRecord: 4.1ms)
I have tried to override app/controllers/spree/admin/users_controller_decorator.rb
module Spree
module Admin
UsersController.class_eval do
private
def user_params
params.require(:user).permit(:email, :password, :password_confirmation, :spree_role_ids, :name, :surname, :birthdate)
end
end
end
end
You Cant asign a role admin to any user from frontend side. Please register a user from front end and change it role from backend.