Use the sole collection as the root for a better onboarding experience for new accounts

This commit is contained in:
Jorge Manrubia
2025-11-04 16:59:40 +01:00
parent 2e0ce7bda9
commit 2bb90eab13
12 changed files with 40 additions and 9 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ module Authentication
end
def after_authentication_url
session.delete(:return_to_after_authenticating) || root_url
session.delete(:return_to_after_authenticating) || landing_url
end
def redirect_authenticated_user
+1 -1
View File
@@ -15,7 +15,7 @@ class JoinCodesController < ApplicationController
identity.send_magic_link
end
session[:return_to_after_authenticating] = root_url(script_name: "/#{tenant}")
session[:return_to_after_authenticating] = landing_url(script_name: "/#{tenant}")
redirect_to session_magic_link_path
end
+9
View File
@@ -0,0 +1,9 @@
class LandingsController < ApplicationController
def show
if Current.user.collections.many?
redirect_to events_path
else
redirect_to collection_path(Current.user.collections.first)
end
end
end
+1 -1
View File
@@ -11,7 +11,7 @@ class Users::JoinsController < ApplicationController
User.create!(user_params.merge(membership: Current.membership))
end
redirect_to root_path
redirect_to landing_path
end
private
@@ -2,7 +2,7 @@
<% cache [ Current.identity, @memberships ] do %>
<%= collapsible_nav_section "Accounts" do %>
<% @memberships.each do |membership| %>
<%= filter_place_menu_item root_url(script_name: "/#{membership.tenant}"), "#{membership.account_name}", "marker", new_window: true %>
<%= filter_place_menu_item landing_url(script_name: "/#{membership.tenant}"), "#{membership.account_name}", "marker", new_window: true %>
<% end %>
<% end %>
<% end %>
+1 -1
View File
@@ -13,7 +13,7 @@
<% @memberships.each do |membership| %>
<li class="popup__item txt-medium">
<%= icon_tag "marker", class: "popup__icon" %>
<%= link_to root_url(script_name: "/#{membership.tenant}"), class: "btn overflow-ellipsis fill-transparent popup__btn" do %>
<%= link_to landing_url(script_name: "/#{membership.tenant}"), class: "btn overflow-ellipsis fill-transparent popup__btn" do %>
<strong><%= membership.account_name %></strong>
<% end %>
</li>
+2
View File
@@ -15,6 +15,8 @@ Rails.application.routes.draw do
end
end
resource :landing
resources :collections do
scope module: :collections do
resource :subscriptions
@@ -13,7 +13,7 @@ class Signups::CompletionsController < ApplicationController
@signup = Signup.new(signup_params)
if @signup.complete
redirect_to root_url(script_name: "/#{@signup.tenant}")
redirect_to landing_url(script_name: "/#{@signup.tenant}")
else
render :new, status: :unprocessable_entity
end
@@ -33,7 +33,7 @@ class Signups::CompletionsControllerTest < ActionDispatch::IntegrationTest
}, headers: http_basic_auth_headers
end
assert_redirected_to root_url(script_name: "/#{@signup.tenant}"), "Successful completion should redirect to root in new tenant"
assert_redirected_to landing_path(script_name: "/#{@signup.tenant}"), "Successful completion should redirect to root in new tenant"
untenanted do
post saas.signup_completion_path, params: {
@@ -42,7 +42,7 @@ class JoinCodesControllerTest < ActionDispatch::IntegrationTest
end
assert_redirected_to session_magic_link_path
assert_equal root_url(script_name: "/#{@tenant}"), session[:return_to_after_authenticating]
assert_equal landing_url(script_name: "/#{@tenant}"), session[:return_to_after_authenticating]
end
end
@@ -0,0 +1,20 @@
require "test_helper"
class LandingsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "redirects to the timeline when many collections" do
get landing_path
assert_redirected_to events_path
end
test "redirects to collections when only one collection" do
sole_collection, *collections_to_delete = users(:kevin).collections.to_a
collections_to_delete.each(&:destroy)
get landing_path
assert_redirected_to collection_path(sole_collection)
end
end
@@ -26,7 +26,7 @@ class Users::JoinsControllerTest < ActionDispatch::IntegrationTest
assert_difference -> { User.count }, +1 do
post users_joins_path, params: { user: { name: "Newart Userbaum" } }
assert_redirected_to root_path
assert_redirected_to landing_path
end
end
end