Skip to content

Commit 36b2e9e

Browse files
committed
Redirect unauthenticated users to login page instead of fallback location
1 parent 9ade31f commit 36b2e9e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/controllers/better_together/application_controller.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,13 @@ def user_not_authorized(exception) # rubocop:todo Metrics/AbcSize, Metrics/Metho
158158
]
159159
else
160160
flash[:error] = message # Use flash for regular redirects
161-
redirect_back(fallback_location: home_page_path)
161+
162+
# For unauthenticated users, redirect to login
163+
if current_user.nil?
164+
redirect_to new_user_session_path(locale: I18n.locale)
165+
else
166+
redirect_back(fallback_location: home_page_path)
167+
end
162168
end
163169
end
164170
# rubocop:enable Metrics/MethodLength

0 commit comments

Comments
 (0)