Redirect to login path also if user is disabled

+ update spec as well
This commit is contained in:
Jean-Baptiste Bellet
2022-06-22 15:25:37 +02:00
parent fbf4513e96
commit 4007b17b1e
2 changed files with 12 additions and 1 deletions

View File

@@ -78,7 +78,7 @@ module Spree
def load_object
@user ||= spree_current_user
if @user
if @user && !@user.disabled
authorize! params[:action].to_sym, @user
else
redirect_to main_app.login_path

View File

@@ -111,5 +111,16 @@ describe '
expect(page).to have_content I18n.t(:you_have_no_orders_yet)
end
end
context "as a disabled user" do
before do
user.disabled = '1'
end
it "redirects to the login page" do
visit "/account"
expect(page).to have_current_path("/")
end
end
end
end