Skip to content

Commit

Permalink
Merge pull request #9341 from jibees/9336-redirect-to-login_path-if-u…
Browse files Browse the repository at this point in the history
…ser-is-disabled

Disabled_at logic: redirect to login path if user is disabled
  • Loading branch information
filipefurtad0 authored Aug 17, 2022
2 parents c11b7ed + 4007b17 commit cedfa35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/spree/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def orders_collection

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
Expand Down
11 changes: 11 additions & 0 deletions spec/system/consumer/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,16 @@
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

0 comments on commit cedfa35

Please sign in to comment.