#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
Land everyone on the editor by default, with a per-user processor opt-in (#7890)
Anthony Stirlingf8ad44829a35
diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/security/controller/api/AuthController.java b/app/proprietary/src/main/java/stirling/software/proprietary/security/controller/api/AuthController.javaindex 6661c86395..fc30582123 100644--- a/app/proprietary/src/main/java/stirling/software/proprietary/security/controller/api/AuthController.java+++ b/app/proprietary/src/main/java/stirling/software/proprietary/security/controller/api/AuthController.java@@ -41,6 +41,7 @@ import stirling.software.proprietary.security.model.exception.AuthenticationFailimport stirling.software.proprietary.security.service.CustomUserDetailsService;import stirling.software.proprietary.security.service.JwtServiceInterface;import stirling.software.proprietary.security.service.LoginAttemptService;+import stirling.software.proprietary.security.service.LoginLandingService;import stirling.software.proprietary.security.service.MfaService;import stirling.software.proprietary.security.service.RefreshRateLimitService;import stirling.software.proprietary.security.service.TotpService;@@ -68,6 +69,7 @@ public class AuthController {private final AiUserDataService aiUserDataService;private final ResourceAccessService resourceAccessService;private final TeamLeadLookup teamLeadLookup;+ private final LoginLandingService loginLandingService;/*** Login endpoint - replaces Supabase signInWithPassword@@ -637,6 +639,7 @@ public class AuthController {userMap.put("enabled", user.isEnabled());userMap.put("portalAccess", resourceAccessService.canAccessPortal(user));userMap.put("teamLead", teamLeadLookup.isAnyTeamLeader(user));+ userMap.put("loginLandingView", loginLandingService.getLandingView(user).value());// Expose the caller's team so non-admin team owners can scope their own team's resources.if (user.getTeam() != null) {userMap.put(diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/security/controller/api/UserController.java b/app/proprietary/src/main/java/stirling/software/proprietary/security/controller/api/UserController.javaindex 2385eb011f..0f7add4a87 100644--- a/app/proprietary/src/main/java/stirling/software/proprietary/security/controller/api/UserController.java+++ b/app/proprietary/src/main/java/stirling/software/proprietary/security/controller/api/UserController.java@@ -43,12 +43,15 @@ import stirling.software.proprietary.audit.Audited;import stirling.software.proprietary.model.Team;import stirling.software.proprietary.security.database.repository.UserRepository;import stirling.software.proprietary.security.model.AuthenticationType;+import stirling.software.proprietary.security.model.LoginLandingView;import stirling.software.proprietary.security.model.User;+import stirling.software.proprietary.security.model.api.user.UpdateLoginLandingView;import stirling.software.proprietary.security.model.api.user.UsernameAndPass;import stirling.software.proprietary.security.repository.TeamRepository;import stirling.software.proprietary.security.saml2.CustomSaml2AuthenticatedPrincipal;import stirling.software.proprietary.security.service.EmailService;import stirling.software.proprietary.security.service.LoginAttemptService;+import stirling.software.proprietary.security.service.LoginLandingService;import stirling.software.proprietary.security.service.SaveUserRequest;import stirling.software.proprietary.security.service.TeamMembershipService;import stirling.software.proprietary.security.service.TeamService;@@ -71,6 +74,7 @@ public class UserController {private final UserLicenseSettingsService licenseSettingsService;private final LoginAttemptService loginAttemptService;private final TeamMembershipService teamMembershipService;+ private final LoginLandingService loginLandingService;@PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")@PostMapping("/register")@@ -362,6 +366,24 @@ public class UserController {return ResponseEntity.ok(Map.of("message", "Settings updated successfully"));}+ @PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")+ @PostMapping("/login-landing-view")+ public ResponseEntity<?> updateLoginLandingView(+ @RequestBody UpdateLoginLandingView request, Principal principal)+ throws SQLException, UnsupportedProviderException {+ if (principal == null) {+ return ResponseEntity.status(HttpStatus.UNAUTHORIZED)+ .body(Map.of("error", "Not authenticated"));+ }+ Optional<LoginLandingView> view = LoginLandingView.parse(request.getLoginLandingView());+ if (view.isEmpty()) {+ return ResponseEntity.badRequest()+ .body(Map.of("error", "loginLandingView must be one of: editor, processor"));+ }+ loginLandingService.setLandingView(principal.getName(), view.get());+ return ResponseEntity.ok(Map.of("loginLandingView", view.get().value()));+ }+@PreAuthorize("hasRole('ADMIN')")@PostMapping("/admin/saveUser")public ResponseEntity<?> saveUser(diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/security/model/LoginLandingView.java b/app/proprietary/src/main/java/stirling/software/proprietary/security/model/LoginLandingView.javanew file mode 100644index 0000000000..0217c67ca3--- /dev/null+++ b/app/proprietary/src/main/java/stirling/software/proprietary/security/model/LoginLandingView.java@@ -0,0 +1,24 @@+package stirling.software.proprietary.security.model;++import java.util.Arrays;+import java.util.Locale;+import java.util.Optional;++public enum LoginLandingView {+ EDITOR,+ PROCESSOR;++ public String value() {+ return name().toLowerCase(Locale.ROOT);+ }++ public static Optional<LoginLandingView> parse(String value) {+ if (value == null) {+ return Optional.empty();+ }+ String trimmed = value.trim();+ return Arrays.stream(values())+ .filter(view -> view.name().equalsIgnoreCase(trimmed))+ .findFirst();+ }+}diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/security/model/api/user/UpdateLoginLandingView.java b/app/proprietary/src/main/java/stirling/software/proprietary/security/model/api/user/UpdateLoginLandingView.javanew file mode 100644index 0000000000..45d4714203--- /dev/null+++ b/app/proprietary/src/main/java/stirling/software/proprietary/security/model/api/user/UpdateLoginLandingView.java@@ -0,0 +1,14 @@+package stirling.software.proprietary.security.model.api.user;++import io.swagger.v3.oas.annotations.media.Schema;++import lombok.Data;++@Data+public class UpdateLoginLandingView {++ @Schema(+ description = "Which app to open after signing in",+ allowableValues = {"editor", "processor"})+ private String loginLandingView;+}diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/security/service/LoginLandingService.java b/app/proprietary/src/main/java/stirling/software/proprietary/security/service/LoginLandingService.javanew file mode 100644index 0000000000..f3e2243bd1--- /dev/null+++ b/app/proprietary/src/main/java/stirling/software/proprietary/security/service/LoginLandingService.java@@ -0,0 +1,59 @@+package stirling.software.proprietary.security.service;++import java.sql.SQLException;+import java.util.HashMap;+import java.util.Map;++import org.springframework.security.core.userdetails.UsernameNotFoundException;+import org.springframework.stereotype.Service;+import org.springframework.transaction.annotation.Transactional;++import lombok.RequiredArgsConstructor;+import lombok.extern.slf4j.Slf4j;++import stirling.software.common.model.exception.UnsupportedProviderException;+import stirling.software.proprietary.security.database.repository.UserRepository;+import stirling.software.proprietary.security.model.LoginLandingView;+import stirling.software.proprietary.security.model.User;++@Service+@RequiredArgsConstructor+@Slf4j+public class LoginLandingService {++ public static final String LOGIN_LANDING_VIEW_KEY = "loginLandingView";++ private final UserRepository userRepository;+ private final DatabaseServiceInterface databaseService;++ public LoginLandingView getLandingView(User user) {+ if (user == null || user.getId() == null) {+ return LoginLandingView.EDITOR;+ }+ return userRepository+ .findByIdWithSettings(user.getId())+ .map(User::getSettings)+ .map(settings -> settings.get(LOGIN_LANDING_VIEW_KEY))+ .flatMap(LoginLandingView::parse)+ .orElse(LoginLandingView.EDITOR);+ }++ @Transactional+ public void setLandingView(String username, LoginLandingView view)+ throws SQLException, UnsupportedProviderException {+ User user =+ userRepository+ .findByUsernameIgnoreCaseWithSettings(username)+ .orElseThrow(+ () -> new UsernameNotFoundException("User not found: " + username));+ Map<String, String> settings = user.getSettings();+ if (settings == null) {+ settings = new HashMap<>();+ user.setSettings(settings);+ }+ settings.put(LOGIN_LANDING_VIEW_KEY, view.value());+ userRepository.save(user);+ databaseService.exportDatabase();+ log.debug("Set landing view to {} for user {}", view.value(), username);+ }+}diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/AuthControllerLoginTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/AuthControllerLoginTest.javaindex 6586fc11b6..bbbbedfedc 100644--- a/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/AuthControllerLoginTest.java+++ b/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/AuthControllerLoginTest.java@@ -2,6 +2,7 @@ package stirling.software.proprietary.security.controller.api;import static org.mockito.ArgumentMatchers.any;import static org.mockito.ArgumentMatchers.eq;+import static org.mockito.Mockito.lenient;import static org.mockito.Mockito.never;import static org.mockito.Mockito.verify;import static org.mockito.Mockito.when;@@ -32,11 +33,13 @@ import stirling.software.proprietary.access.service.ResourceAccessService;import stirling.software.proprietary.access.service.TeamLeadLookup;import stirling.software.proprietary.security.model.AuthenticationType;import stirling.software.proprietary.security.model.Authority;+import stirling.software.proprietary.security.model.LoginLandingView;import stirling.software.proprietary.security.model.User;import stirling.software.proprietary.security.model.api.user.UsernameAndPassMfa;import stirling.software.proprietary.security.service.CustomUserDetailsService;import stirling.software.proprietary.security.service.JwtServiceInterface;import stirling.software.proprietary.security.service.LoginAttemptService;+import stirling.software.proprietary.security.service.LoginLandingService;import stirling.software.proprietary.security.service.MfaService;import stirling.software.proprietary.security.service.RefreshRateLimitService;import stirling.software.proprietary.security.service.TotpService;@@ -62,6 +65,7 @@ class AuthControllerLoginTest {@Mock private RefreshRateLimitService refreshRateLimitService;@Mock private ResourceAccessService resourceAccessService;@Mock private TeamLeadLookup teamLeadLookup;+ @Mock private LoginLandingService loginLandingService;@BeforeEachvoid setUp() {@@ -86,7 +90,11 @@ class AuthControllerLoginTest {applicationProperties,new stirling.software.proprietary.service.AiUserDataService(null),resourceAccessService,- teamLeadLookup);+ teamLeadLookup,+ loginLandingService);+ lenient()+ .when(loginLandingService.getLandingView(any()))+ .thenReturn(LoginLandingView.EDITOR);mockMvc = MockMvcBuilders.standaloneSetup(controller).build();}@@ -177,7 +185,8 @@ class AuthControllerLoginTest {.content(objectMapper.writeValueAsString(payload))).andExpect(status().isOk()).andExpect(jsonPath("$.session.access_token").value("token-123"))- .andExpect(jsonPath("$.user.username").value("[email protected]"));+ .andExpect(jsonPath("$.user.username").value("[email protected]"))+ .andExpect(jsonPath("$.user.loginLandingView").value("editor"));verify(loginAttemptService).loginSucceeded("[email protected]");}@@ -304,6 +313,21 @@ class AuthControllerLoginTest {SecurityContextHolder.clearContext();}+ @Test+ void getCurrentUserCarriesTheProcessorOptIn() throws Exception {+ User user = buildUser();+ when(loginLandingService.getLandingView(any())).thenReturn(LoginLandingView.PROCESSOR);+ SecurityContextHolder.getContext()+ .setAuthentication(+ new UsernamePasswordAuthenticationToken(user, null, user.getAuthorities()));++ mockMvc.perform(get("/api/v1/auth/me"))+ .andExpect(status().isOk())+ .andExpect(jsonPath("$.user.loginLandingView").value("processor"));++ SecurityContextHolder.clearContext();+ }+private User buildUser() {User user = new User();user.setUsername("[email protected]");diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/AuthControllerMoreTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/AuthControllerMoreTest.javaindex aaf931f597..20cb873369 100644--- a/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/AuthControllerMoreTest.java+++ b/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/AuthControllerMoreTest.java@@ -1,6 +1,7 @@package stirling.software.proprietary.security.controller.api;import static org.mockito.ArgumentMatchers.any;+import static org.mockito.Mockito.lenient;import static org.mockito.Mockito.never;import static org.mockito.Mockito.verify;import static org.mockito.Mockito.when;@@ -32,11 +33,13 @@ import stirling.software.proprietary.access.service.ResourceAccessService;import stirling.software.proprietary.access.service.TeamLeadLookup;import stirling.software.proprietary.security.model.AuthenticationType;import stirling.software.proprietary.security.model.Authority;+import stirling.software.proprietary.security.model.LoginLandingView;import stirling.software.proprietary.security.model.User;import stirling.software.proprietary.security.model.api.user.UsernameAndPassMfa;import stirling.software.proprietary.security.service.CustomUserDetailsService;import stirling.software.proprietary.security.service.JwtServiceInterface;import stirling.software.proprietary.security.service.LoginAttemptService;+import stirling.software.proprietary.security.service.LoginLandingService;import stirling.software.proprietary.security.service.MfaService;import stirling.software.proprietary.security.service.RefreshRateLimitService;import stirling.software.proprietary.security.service.TotpService;@@ -63,6 +66,7 @@ class AuthControllerMoreTest {@Mock private RefreshRateLimitService refreshRateLimitService;@Mock private ResourceAccessService resourceAccessService;@Mock private TeamLeadLookup teamLeadLookup;+ @Mock private LoginLandingService loginLandingService;@BeforeEachvoid setUp() {@@ -87,7 +91,11 @@ class AuthControllerMoreTest {applicationProperties,new stirling.software.proprietary.service.AiUserDataService(null),resourceAccessService,- teamLeadLookup);+ teamLeadLookup,+ loginLandingService);+ lenient()+ .when(loginLandingService.getLandingView(any()))+ .thenReturn(LoginLandingView.EDITOR);mockMvc = MockMvcBuilders.standaloneSetup(controller).build();}diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/UserControllerMoreTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/UserControllerMoreTest.javaindex ac2219efa3..ff1b9f53c0 100644--- a/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/UserControllerMoreTest.java+++ b/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/UserControllerMoreTest.java@@ -30,6 +30,7 @@ import stirling.software.proprietary.security.model.User;import stirling.software.proprietary.security.repository.TeamRepository;import stirling.software.proprietary.security.service.EmailService;import stirling.software.proprietary.security.service.LoginAttemptService;+import stirling.software.proprietary.security.service.LoginLandingService;import stirling.software.proprietary.security.service.TeamMembershipService;import stirling.software.proprietary.security.service.TeamService;import stirling.software.proprietary.security.service.UserService;@@ -48,6 +49,7 @@ class UserControllerMoreTest {@Mock private UserLicenseSettingsService licenseSettingsService;@Mock private LoginAttemptService loginAttemptService;@Mock private TeamMembershipService teamMembershipService;+ @Mock private LoginLandingService loginLandingService;private ApplicationProperties applicationProperties;private MockMvc mockMvc;@@ -67,7 +69,8 @@ class UserControllerMoreTest {Optional.of(emailService),licenseSettingsService,loginAttemptService,- teamMembershipService);+ teamMembershipService,+ loginLandingService);mockMvc = MockMvcBuilders.standaloneSetup(controller).build();}diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/UserControllerTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/UserControllerTest.javaindex b3a1e8de93..2b2aa2e07c 100644--- a/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/UserControllerTest.java+++ b/app/proprietary/src/test/java/stirling/software/proprietary/security/controller/api/UserControllerTest.java@@ -28,11 +28,14 @@ import stirling.software.common.model.ApplicationProperties;import stirling.software.proprietary.model.Team;import stirling.software.proprietary.security.database.repository.UserRepository;import stirling.software.proprietary.security.model.AuthenticationType;+import stirling.software.proprietary.security.model.LoginLandingView;import stirling.software.proprietary.security.model.User;+import stirling.software.proprietary.security.model.api.user.UpdateLoginLandingView;import stirling.software.proprietary.security.model.api.user.UsernameAndPass;import stirling.software.proprietary.security.repository.TeamRepository;import stirling.software.proprietary.security.service.EmailService;import stirling.software.proprietary.security.service.LoginAttemptService;+import stirling.software.proprietary.security.service.LoginLandingService;import stirling.software.proprietary.security.service.TeamMembershipService;import stirling.software.proprietary.security.service.TeamService;import stirling.software.proprietary.security.service.UserService;@@ -55,6 +58,7 @@ class UserControllerTest {@Mock private UserLicenseSettingsService licenseSettingsService;@Mock private LoginAttemptService loginAttemptService;@Mock private TeamMembershipService teamMembershipService;+ @Mock private LoginLandingService loginLandingService;private ApplicationProperties applicationProperties;private MockMvc mockMvc;@@ -75,7 +79,8 @@ class UserControllerTest {Optional.of(emailService),licenseSettingsService,loginAttemptService,- teamMembershipService);+ teamMembershipService,+ loginLandingService);mockMvc = MockMvcBuilders.standaloneSetup(controller).build();}@@ -149,6 +154,39 @@ class UserControllerTest {.andExpect(jsonPath("$.error").value("User not found."));}+ @Test+ void updateLoginLandingViewStoresTheOptIn() throws Exception {+ UpdateLoginLandingView payload = new UpdateLoginLandingView();+ payload.setLoginLandingView("processor");+ Authentication authentication = new UsernamePasswordAuthenticationToken("lead", "pw");++ mockMvc.perform(+ post("/api/v1/user/login-landing-view")+ .principal(authentication)+ .contentType(MediaType.APPLICATION_JSON)+ .content(objectMapper.writeValueAsString(payload)))+ .andExpect(status().isOk())+ .andExpect(jsonPath("$.loginLandingView").value("processor"));++ verify(loginLandingService).setLandingView("lead", LoginLandingView.PROCESSOR);+ }++ @Test+ void updateLoginLandingViewRejectsAnUnknownView() throws Exception {+ UpdateLoginLandingView payload = new UpdateLoginLandingView();+ payload.setLoginLandingView("portal");+ Authentication authentication = new UsernamePasswordAuthenticationToken("lead", "pw");++ mockMvc.perform(+ post("/api/v1/user/login-landing-view")+ .principal(authentication)+ .contentType(MediaType.APPLICATION_JSON)+ .content(objectMapper.writeValueAsString(payload)))+ .andExpect(status().isBadRequest());++ verify(loginLandingService, never()).setLandingView(any(), any());+ }+@Testvoid unlockUserCallsResetAttemptsAndReturnsOk() throws Exception {mockMvc.perform(post("/api/v1/user/admin/unlockUser/lockeduser"))diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/security/service/LoginLandingServiceTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/security/service/LoginLandingServiceTest.javanew file mode 100644index 0000000000..49deabd9e1--- /dev/null+++ b/app/proprietary/src/test/java/stirling/software/proprietary/security/service/LoginLandingServiceTest.java@@ -0,0 +1,64 @@+package stirling.software.proprietary.security.service;++import static org.junit.jupiter.api.Assertions.assertEquals;+import static org.mockito.Mockito.verify;+import static org.mockito.Mockito.when;++import java.util.Optional;++import org.junit.jupiter.api.Test;+import org.junit.jupiter.api.extension.ExtendWith;+import org.mockito.InjectMocks;+import org.mockito.Mock;+import org.mockito.junit.jupiter.MockitoExtension;++import stirling.software.proprietary.security.database.repository.UserRepository;+import stirling.software.proprietary.security.model.LoginLandingView;+import stirling.software.proprietary.security.model.User;++@ExtendWith(MockitoExtension.class)+class LoginLandingServiceTest {++ @Mock private UserRepository userRepository;+ @Mock private DatabaseServiceInterface databaseService;++ @InjectMocks private LoginLandingService loginLandingService;++ private static User user(String storedValue) {+ User user = new User();+ user.setId(7L);+ user.setUsername("[email protected]");+ if (storedValue != null) {+ user.getSettings().put(LoginLandingService.LOGIN_LANDING_VIEW_KEY, storedValue);+ }+ return user;+ }++ @Test+ void defaultsToEditorWhenUnset() {+ when(userRepository.findByIdWithSettings(7L)).thenReturn(Optional.of(user(null)));++ assertEquals(LoginLandingView.EDITOR, loginLandingService.getLandingView(user(null)));+ }++ @Test+ void returnsProcessorWhenOptedIn() {+ when(userRepository.findByIdWithSettings(7L)).thenReturn(Optional.of(user("processor")));++ assertEquals(LoginLandingView.PROCESSOR, loginLandingService.getLandingView(user(null)));+ }++ @Test+ void setLandingViewStoresTheWireValueAndExports() throws Exception {+ User stored = user(null);+ when(userRepository.findByUsernameIgnoreCaseWithSettings("[email protected]"))+ .thenReturn(Optional.of(stored));++ loginLandingService.setLandingView("[email protected]", LoginLandingView.PROCESSOR);++ assertEquals(+ "processor", stored.getSettings().get(LoginLandingService.LOGIN_LANDING_VIEW_KEY));+ verify(userRepository).save(stored);+ verify(databaseService).exportDatabase();+ }+}diff --git a/frontend/editor/public/locales/en-US/translation.toml b/frontend/editor/public/locales/en-US/translation.tomlindex b05fe1dc53..61712803e0 100644--- a/frontend/editor/public/locales/en-US/translation.toml+++ b/frontend/editor/public/locales/en-US/translation.toml@@ -10625,12 +10625,6 @@ intro = "Enable user authentication, team management, and workspace features forlearnMore = "Learn more in documentation"title = "For System Administrators"-[settings.general.loginLanding]-description = "Choose which app opens when you sign in to Stirling Cloud."-editor = "Editor"-processor = "Processor"-title = "After signing in"-[settings.general.mode]fullscreen = "Fullscreen"sidebar = "Sidebar"diff --git a/frontend/editor/src/core/routes/editorBasename.ts b/frontend/editor/src/core/routes/editorBasename.tsindex a37f8d80ec..dc24fa7d65 100644--- a/frontend/editor/src/core/routes/editorBasename.ts+++ b/frontend/editor/src/core/routes/editorBasename.ts@@ -4,7 +4,7 @@** Core ships no processor, so there is nothing for "/" to route between and the* editor simply owns the root. Builds that DO ship a processor override this- * (see the proprietary copy): there "/" is a role-based router and the editor+ * (see the proprietary copy): there "/" is a landing router and the editor* moves to its own URL.*/export const EDITOR_BASENAME = "/";diff --git a/frontend/editor/src/core/services/preferencesService.ts b/frontend/editor/src/core/services/preferencesService.tsindex a378136665..bba1eadc22 100644--- a/frontend/editor/src/core/services/preferencesService.ts+++ b/frontend/editor/src/core/services/preferencesService.ts@@ -21,18 +21,12 @@ export type ViewerZoomSetting =| "150"| "200";-// SaaS-only: which app a team lead lands on after signing in. Members can't-// reach the processor, so this never applies to them.-export type LoginLandingView = "processor" | "editor";-export interface UserPreferences {autoUnzip: boolean;autoUnzipFileLimit: number;defaultToolPanelMode: ToolPanelMode;defaultStartupView: StartupView;defaultViewerZoom: ViewerZoomSetting;- // SaaS-only: team lead's post-login landing app (processor vs editor).- loginLandingView: LoginLandingView;theme: ThemeMode;toolPanelModePromptSeen: boolean;hasSelectedToolPanelMode: boolean;@@ -52,7 +46,6 @@ export const DEFAULT_PREFERENCES: UserPreferences = {defaultToolPanelMode: DEFAULT_TOOL_PANEL_MODE,defaultStartupView: "tools",defaultViewerZoom: "auto",- loginLandingView: "processor",theme: "system",toolPanelModePromptSeen: false,hasSelectedToolPanelMode: false,diff --git a/frontend/editor/src/core/tests/helpers/stub-test-base.ts b/frontend/editor/src/core/tests/helpers/stub-test-base.tsindex 295d5b2184..8419b93e28 100644--- a/frontend/editor/src/core/tests/helpers/stub-test-base.ts+++ b/frontend/editor/src/core/tests/helpers/stub-test-base.ts@@ -54,7 +54,7 @@ const STUB_JWT = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzdHViLXVzZXIifQ.signature";export const test = base.extend<StubFixtures>({stubOptions: [{}, { option: true }],- // The editor's own URL, not "/". "/" is a role-based router that redirects,+ // The editor's own URL, not "/". "/" is a landing router that redirects,// and /editor renders the editor in every flavour, so tests land straight on// the app instead of racing a redirect on every single test.autoGoto: ["/editor", { option: true }],diff --git a/frontend/editor/src/portal/auth/editorUrl.ts b/frontend/editor/src/portal/auth/editorUrl.tsindex 30c6a5b182..ecdccc3e44 100644--- a/frontend/editor/src/portal/auth/editorUrl.ts+++ b/frontend/editor/src/portal/auth/editorUrl.ts@@ -23,8 +23,8 @@ export const EDITOR_IS_SAME_APP =* served under /app) lands on /app/editor rather than the origin root. These* CTAs use window.location, which bypasses the router basename, so the base* path has to be baked in here. Targeting EDITOR_BASENAME rather than "/" also- * keeps the switch out of the role-based router, which would bounce a processor- * user straight back. For dev cross-app navigation to a separately-running+ * keeps the switch out of the landing router at "/", which would bounce a+ * processor user straight back. For dev cross-app navigation to a separately-running* editor, set VITE_EDITOR_URL in editor/.env.local.*/export const EDITOR_URL = EDITOR_IS_SAME_APPdiff --git a/frontend/editor/src/proprietary/components/notifications/notificationActions.test.tsx b/frontend/editor/src/proprietary/components/notifications/notificationActions.test.tsxindex 36d56822b6..2754a6870b 100644--- a/frontend/editor/src/proprietary/components/notifications/notificationActions.test.tsx+++ b/frontend/editor/src/proprietary/components/notifications/notificationActions.test.tsx@@ -337,7 +337,7 @@ describe("useNotificationActions", () => {expect(setWorkbench).toHaveBeenCalledWith("viewer");});- it("stays where it is rather than routing through the role-based root", async () => {+ it("stays where it is rather than routing through the landing root", async () => {// "/" lands on a page chosen by the reader's role, which reads as the app reloading.await registry().VIEW_FILE?.run(context());diff --git a/frontend/editor/src/proprietary/components/notifications/notificationActions.ts b/frontend/editor/src/proprietary/components/notifications/notificationActions.tsindex 4aa1d1d50a..dc34d828a0 100644--- a/frontend/editor/src/proprietary/components/notifications/notificationActions.ts+++ b/frontend/editor/src/proprietary/components/notifications/notificationActions.ts@@ -234,7 +234,7 @@ export function useNotificationActions(): ClientActionRegistry {): Promise<ClientActionOutcome | void> => {if (!fileId) return;- // In place: "/" is the role-based router, which lands the user wherever their role says.+ // In place: "/" is the landing router, which redirects wherever the account belongs.if (canOpenHere) {return (await openInWorkbench(fileId)) ? undefined : { ok: false };}diff --git a/frontend/editor/src/proprietary/components/shared/config/GeneralWithLoginLanding.stories.tsx b/frontend/editor/src/proprietary/components/shared/config/GeneralWithLoginLanding.stories.tsxdeleted file mode 100644index 2c8fb2aa3b..0000000000--- a/frontend/editor/src/proprietary/components/shared/config/GeneralWithLoginLanding.stories.tsx+++ /dev/null@@ -1,74 +0,0 @@-import type { Meta, StoryObj } from "@storybook/react-vite";-import GeneralWithLoginLanding from "@app/components/shared/config/GeneralWithLoginLanding";-import { PreferencesProvider } from "@app/contexts/PreferencesContext";-import { ThemeProvider } from "@app/components/shared/ThemeProvider";-import { AppConfigProvider } from "@app/contexts/AppConfigContext";--// Wraps GeneralSection, which reads theme/tool-panel preferences via-// usePreferences()/useTheme() and server config via useAppConfig() — none of-// which the Storybook preview's own provider tree supplies (those are the-// portal contexts), so wrap here. AppConfigProvider uses autoFetch off so-// stories render a fixed config instead of hitting the API. The login-landing-// control itself stays hidden (loginLandingMode() defaults to non-"dynamic"-// in this build), so only the General section is visible.-const meta = {- title: "Config/GeneralWithLoginLanding",- component: GeneralWithLoginLanding,- parameters: { layout: "padded" },- decorators: [- (Story) => (- <PreferencesProvider>- <ThemeProvider>- <Story />- </ThemeProvider>- </PreferencesProvider>- ),- ],-} satisfies Meta<typeof GeneralWithLoginLanding>;-export default meta;-type Story = StoryObj<typeof meta>;--/** Login enabled, no backend version known yet — Software Updates section and admin banner stay hidden. */-export const Default: Story = {- decorators: [- (StoryComponent) => (- <AppConfigProvider- autoFetch={false}- bootstrapMode="non-blocking"- initialConfig={{ enableLogin: true }}- >- <StoryComponent />- </AppConfigProvider>- ),- ],-};--/** Backend version known — shows the Software Updates section with version info. */-export const WithBackendVersion: Story = {- decorators: [- (StoryComponent) => (- <AppConfigProvider- autoFetch={false}- bootstrapMode="non-blocking"- initialConfig={{ enableLogin: true, appVersion: "1.2.3" }}- >- <StoryComponent />- </AppConfigProvider>- ),- ],-};--/** Login disabled — the "For System Administrators" banner shows, prompting the env vars to enable it. */-export const AdminBanner: Story = {- decorators: [- (StoryComponent) => (- <AppConfigProvider- autoFetch={false}- bootstrapMode="non-blocking"- initialConfig={{ enableLogin: false }}- >- <StoryComponent />- </AppConfigProvider>- ),- ],-};diff --git a/frontend/editor/src/proprietary/components/shared/config/GeneralWithLoginLanding.tsx b/frontend/editor/src/proprietary/components/shared/config/GeneralWithLoginLanding.tsxdeleted file mode 100644index ad04cce95e..0000000000--- a/frontend/editor/src/proprietary/components/shared/config/GeneralWithLoginLanding.tsx+++ /dev/null@@ -1,19 +0,0 @@-import type { ComponentProps } from "react";-import { Stack } from "@mantine/core";-import GeneralSection from "@app/components/shared/config/configSections/GeneralSection";-import { LoginLandingSetting } from "@app/components/shared/config/LoginLandingSetting";--type GeneralSectionProps = ComponentProps<typeof GeneralSection>;--/**- * Core General settings plus the shared login-landing control. Used by every- * flavor's config nav so the setting is not duplicated per flavor.- */-export default function GeneralWithLoginLanding(props: GeneralSectionProps) {- return (- <Stack gap="lg">- <GeneralSection {...props} />- <LoginLandingSetting />- </Stack>- );-}diff --git a/frontend/editor/src/proprietary/components/shared/config/LoginLandingSetting.test.tsx b/frontend/editor/src/proprietary/components/shared/config/LoginLandingSetting.test.tsxdeleted file mode 100644index b9caf6ba8d..0000000000--- a/frontend/editor/src/proprietary/components/shared/config/LoginLandingSetting.test.tsx+++ /dev/null@@ -1,101 +0,0 @@-import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";-import { render, screen, waitFor } from "@testing-library/react";-import { MantineProvider } from "@mantine/core";--const h = vi.hoisted(() => ({- prefs: { loginLandingView: "processor" },- update: vi.fn(),- get: vi.fn(),-}));--vi.mock("@app/services/apiClient", () => ({ default: { get: h.get } }));-vi.mock("@app/contexts/PreferencesContext", () => ({- usePreferences: () => ({ preferences: h.prefs, updatePreference: h.update }),-}));-vi.mock("react-i18next", () => ({- useTranslation: () => ({- t: (_key: string, fallback?: string) => fallback ?? _key,- i18n: { changeLanguage: vi.fn() },- }),-}));--import { LoginLandingSetting } from "@app/components/shared/config/LoginLandingSetting";--function httpError(status: number) {- return Object.assign(new Error("http"), { response: { status } });-}--// Self-hosted admin (portalAccess true, no /team/my) → eligible.-function eligibleBackend() {- h.get.mockImplementation((url: string) => {- if (url === "/api/v1/auth/me") {- return Promise.resolve({- data: { user: { role: "ROLE_ADMIN", portalAccess: true } },- });- }- return Promise.reject(httpError(404));- });-}--// Self-hosted member (no portalAccess) → not eligible.-function memberBackend() {- h.get.mockImplementation((url: string) => {- if (url === "/api/v1/auth/me") {- return Promise.resolve({- data: { user: { role: "USER", portalAccess: false } },- });- }- return Promise.reject(httpError(404));- });-}--function renderSetting() {- return render(- <MantineProvider>- <LoginLandingSetting />- </MantineProvider>,- );-}--beforeEach(() => {- vi.stubEnv("VITE_INCLUDE_PORTAL", "true");- vi.stubEnv("VITE_LOGIN_LANDING_MODE", "dynamic");- h.prefs = { loginLandingView: "processor" };- h.update.mockReset();- h.get.mockReset();-});--afterEach(() => vi.unstubAllEnvs());--describe("LoginLandingSetting", () => {- it("shows the control for a processor user", async () => {- eligibleBackend();- renderSetting();- expect(await screen.findByText("After signing in")).toBeInTheDocument();- expect(screen.getByText("Processor")).toBeInTheDocument();- expect(screen.getByText("Editor")).toBeInTheDocument();- });-- it("renders nothing for a member", async () => {- memberBackend();- renderSetting();- await waitFor(() => expect(h.get).toHaveBeenCalled());- await Promise.resolve();- expect(screen.queryByText("After signing in")).not.toBeInTheDocument();- });-- it("renders nothing in editor mode (soft release)", () => {- vi.stubEnv("VITE_LOGIN_LANDING_MODE", "editor");- eligibleBackend();- renderSetting();- expect(screen.queryByText("After signing in")).not.toBeInTheDocument();- });-- it("renders nothing when the portal is not bundled", () => {- vi.stubEnv("VITE_INCLUDE_PORTAL", "");- vi.stubEnv("DEV", false);- eligibleBackend();- renderSetting();- expect(screen.queryByText("After signing in")).not.toBeInTheDocument();- });-});diff --git a/frontend/editor/src/proprietary/components/shared/config/LoginLandingSetting.tsx b/frontend/editor/src/proprietary/components/shared/config/LoginLandingSetting.tsxdeleted file mode 100644index 3ff1aebf64..0000000000--- a/frontend/editor/src/proprietary/components/shared/config/LoginLandingSetting.tsx+++ /dev/null@@ -1,85 +0,0 @@-import { useEffect, useState } from "react";-import { Paper, Text } from "@mantine/core";-import { useTranslation } from "react-i18next";-import { SegmentedControl } from "@app/ui/SegmentedControl";-import { usePreferences } from "@app/contexts/PreferencesContext";-import type { LoginLandingView } from "@app/services/preferencesService";-import {- fetchRootDestination,- isPortalAvailable,- loginLandingMode,-} from "@app/utils/loginLanding";--/**- * Processor-user preference: where to land after signing in (processor vs- * editor). Shown only to users who default to the processor (see- * fetchRootDestination); hidden for members and solo users. Shared by all- * flavors.- */-export function LoginLandingSetting() {- const { t } = useTranslation();- const { preferences, updatePreference } = usePreferences();- const [eligible, setEligible] = useState(false);-- // Only look up eligibility when the control could actually show; skip the- // request entirely in soft-release / no-portal builds.- const active = loginLandingMode() === "dynamic" && isPortalAvailable();- useEffect(() => {- if (!active) return;- let cancelled = false;- void fetchRootDestination().then((destination) => {- if (!cancelled) setEligible(destination === "processor");- });- return () => {- cancelled = true;- };- }, [active]);-- if (!active || !eligible) {- return null;- }-- return (- <Paper withBorder p="md" radius="md">- <div- id="setting-login-landing"- style={{- display: "flex",- alignItems: "center",- justifyContent: "space-between",- gap: "1rem",- }}- >- <div style={{ flex: 1, minWidth: 0 }}>- <Text fw={500} size="sm">- {t("settings.general.loginLanding.title", "After signing in")}- </Text>- <Text size="xs" c="dimmed" mt={4}>- {t(- "settings.general.loginLanding.description",- "Choose which app opens when you sign in.",- )}- </Text>- </div>- <SegmentedControl- value={preferences.loginLandingView}- onChange={(val: string) =>- updatePreference("loginLandingView", val as LoginLandingView)- }- options={[- {- label: t("settings.general.loginLanding.processor", "Processor"),- value: "processor",- },- {- label: t("settings.general.loginLanding.editor", "Editor"),- value: "editor",- },- ]}- />- </div>- </Paper>- );-}--export default LoginLandingSetting;diff --git a/frontend/editor/src/proprietary/components/shared/config/configNavSections.tsx b/frontend/editor/src/proprietary/components/shared/config/configNavSections.tsxindex 618f1e10b7..9ed036aacd 100644--- a/frontend/editor/src/proprietary/components/shared/config/configNavSections.tsx+++ b/frontend/editor/src/proprietary/components/shared/config/configNavSections.tsx@@ -27,7 +27,6 @@ import AdminStorageSharingSection from "@app/components/shared/config/configSectimport AdminFolderAccessSection from "@app/components/shared/config/configSections/AdminFolderAccessSection";import ApiKeys from "@app/components/shared/config/configSections/ApiKeys";import AccountSection from "@app/components/shared/config/configSections/AccountSection";-import GeneralWithLoginLanding from "@app/components/shared/config/GeneralWithLoginLanding";/*** Hook version of proprietary config nav sections with proper i18n support@@ -54,21 +53,13 @@ export const useConfigNavSections = (const preferencesSection = sections.find((section) =>section.items.some((item) => item.key === "general"),);- if (preferencesSection) {- preferencesSection.items = preferencesSection.items.map((item) =>- item.key === "general"- ? { ...item, component: <GeneralWithLoginLanding hideTitle /> }- : item,- );-- if (loginEnabled) {- preferencesSection.items.push({- key: "account",- label: t("account.accountSettings", "Account"),- icon: "person-rounded",- component: <AccountSection />,- });- }+ if (preferencesSection && loginEnabled) {+ preferencesSection.items.push({+ key: "account",+ label: t("account.accountSettings", "Account"),+ icon: "person-rounded",+ component: <AccountSection />,+ });}// Add Admin sections for admins. When login is disabled, keep the historicaldiff --git a/frontend/editor/src/proprietary/routes/Login.tsx b/frontend/editor/src/proprietary/routes/Login.tsxindex 7fd3e86670..5be2f1970d 100644--- a/frontend/editor/src/proprietary/routes/Login.tsx+++ b/frontend/editor/src/proprietary/routes/Login.tsx@@ -41,7 +41,7 @@ export default function Login() {// Where to return to after signing in. Router state first (set when Landing// bounces an unauthenticated visitor), then the query, which is what survives// a reload of /login. Null means "no specific destination" and the caller- // falls back to role-based landing.+ // falls back to the default landing.const resolveReturnPath = (): string | null => {const fromState = (location.state as { from?: { pathname?: string } } | null@@ -216,9 +216,9 @@ export default function Login() {navigate(returnPath, { replace: true });return;}- // No explicit destination: land processor users on the processor and- // everyone else on the editor. Resolved here rather than by bouncing- // through "/" so the app isn't torn down and remounted on the way.+ // No explicit destination: the editor, unless this account opted in to the+ // processor. Resolved here rather than by bouncing through "/" so the app+ // isn't torn down and remounted on the way.let active = true;void resolveLandingPath().then((path) => {if (!active) return;diff --git a/frontend/editor/src/proprietary/routes/RootGate.test.tsx b/frontend/editor/src/proprietary/routes/RootGate.test.tsxindex aeb1065f03..d62414cf2a 100644--- a/frontend/editor/src/proprietary/routes/RootGate.test.tsx+++ b/frontend/editor/src/proprietary/routes/RootGate.test.tsx@@ -3,16 +3,9 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { render, screen, waitFor } from "@testing-library/react";import { MemoryRouter, Route, Routes, useLocation } from "react-router-dom";-// Mutable holders driven per-test; read at call time by the mocks below.-const h = vi.hoisted(() => ({- landingView: "processor" as "processor" | "editor",- get: vi.fn(),-}));+const h = vi.hoisted(() => ({ get: vi.fn() }));vi.mock("@app/services/apiClient", () => ({ default: { get: h.get } }));-vi.mock("@app/services/preferencesService", () => ({- preferencesService: { getPreference: () => h.landingView },-}));import { RootGate } from "@app/routes/RootGate";@@ -20,25 +13,22 @@ function httpError(status: number) {return { isAxiosError: true, message: "http", response: { status } };}-// Configure the two backend endpoints. teamMy === "404" simulates self-hosted.function backend(opts: {- role: string;portalAccess: boolean;- teamMy: unknown[] | "404";+ loginLandingView?: "processor" | "editor";}) {- h.get.mockImplementation((url: string) => {- if (url === "/api/v1/auth/me") {- return Promise.resolve({- data: { user: { role: opts.role, portalAccess: opts.portalAccess } },- });- }- if (url === "/api/v1/team/my") {- return opts.teamMy === "404"- ? Promise.reject(httpError(404))- : Promise.resolve({ data: opts.teamMy });- }- return Promise.resolve({ data: {} });- });+ h.get.mockImplementation((url: string) =>+ url === "/api/v1/auth/me"+ ? Promise.resolve({+ data: {+ user: {+ portalAccess: opts.portalAccess,+ loginLandingView: opts.loginLandingView,+ },+ },+ })+ : Promise.resolve({ data: {} }),+ );}function LocationProbe() {@@ -80,7 +70,6 @@ const appMounted = () => screen.queryByTestId("app") !== null;describe("RootGate", () => {beforeEach(() => {- h.landingView = "processor";h.get.mockReset();// The portal only exists in some builds; the decision is a no-op without it.vi.stubEnv("VITE_INCLUDE_PORTAL", "true");@@ -89,27 +78,27 @@ describe("RootGate", () => {afterEach(() => vi.unstubAllEnvs());it("renders the app untouched on every path but /", async () => {- backend({ role: "ROLE_ADMIN", portalAccess: true, teamMy: "404" });+ backend({ portalAccess: true, loginLandingView: "processor" });renderAt("/compress");expect(appMounted()).toBe(true);expect(at()).toBe("/compress");expect(h.get).not.toHaveBeenCalled();});- it("sends a processor user to the processor", async () => {- backend({ role: "USER", portalAccess: true, teamMy: "404" });+ it("sends an opted-in user to the processor", async () => {+ backend({ portalAccess: true, loginLandingView: "processor" });renderAt("/");await waitFor(() => expect(at()).toBe("/processor"));});- it("sends everyone else to the editor", async () => {- backend({ role: "USER", portalAccess: false, teamMy: "404" });+ it("sends everyone without the opt-in to the editor", async () => {+ backend({ portalAccess: true });renderAt("/");await waitFor(() => expect(at()).toBe("/editor"));});it("never boots the app on the way to the processor", async () => {- backend({ role: "USER", portalAccess: true, teamMy: "404" });+ backend({ portalAccess: true, loginLandingView: "processor" });renderAt("/");expect(appMounted()).toBe(false); // decidingawait waitFor(() => expect(at()).toBe("/processor"));@@ -125,22 +114,14 @@ describe("RootGate", () => {});it("survives StrictMode's double-invoke", async () => {- backend({ role: "USER", portalAccess: true, teamMy: "404" });+ backend({ portalAccess: true, loginLandingView: "processor" });renderAt("/", true);await waitFor(() => expect(at()).toBe("/processor"));});- it("honours the per-user editor override without a lookup", async () => {- h.landingView = "editor";- backend({ role: "ROLE_ADMIN", portalAccess: true, teamMy: "404" });- renderAt("/");- await waitFor(() => expect(at()).toBe("/editor"));- expect(h.get).not.toHaveBeenCalled();- });-- it("routes everyone to the editor when the soft-release flag is off", async () => {+ it("routes everyone to the editor when the kill switch is on", async () => {vi.stubEnv("VITE_LOGIN_LANDING_MODE", "editor");- backend({ role: "ROLE_ADMIN", portalAccess: true, teamMy: "404" });+ backend({ portalAccess: true, loginLandingView: "processor" });renderAt("/");await waitFor(() => expect(at()).toBe("/editor"));expect(h.get).not.toHaveBeenCalled();@@ -149,7 +130,7 @@ describe("RootGate", () => {it("routes to the editor when this build ships no processor", async () => {vi.stubEnv("VITE_INCLUDE_PORTAL", "false");vi.stubEnv("DEV", false);- backend({ role: "ROLE_ADMIN", portalAccess: true, teamMy: "404" });+ backend({ portalAccess: true, loginLandingView: "processor" });renderAt("/");await waitFor(() => expect(at()).toBe("/editor"));expect(h.get).not.toHaveBeenCalled();diff --git a/frontend/editor/src/proprietary/routes/RootGate.tsx b/frontend/editor/src/proprietary/routes/RootGate.tsxindex 3821bec429..a50c2f57b9 100644--- a/frontend/editor/src/proprietary/routes/RootGate.tsx+++ b/frontend/editor/src/proprietary/routes/RootGate.tsx@@ -6,14 +6,14 @@ import { resolveRootTarget } from "@app/utils/loginLanding";/** A decision, tagged with the visit it was made for so it can never go stale. */interface Decision {visit: string;- /** Where to send them, or null for "no role to route on - render the app". */+ /** Where to send them, or null for "no account to route on - render the app". */target: string | null;}/**- * Makes "/" a role-based router instead of a page: signed-in users are sent on- * to the processor or the editor, with a per-user override in Settings and the- * VITE_LOGIN_LANDING_MODE soft-release flag. Every other path renders the app+ * Makes "/" a router instead of a page: signed-in users are sent on to the+ * editor, or to the processor if their account has opted in, subject to the+ * VITE_LOGIN_LANDING_MODE kill switch. Every other path renders the app* untouched.** Wraps the app rather than being a route of its own, which buys two things:@@ -35,9 +35,9 @@ interface Decision {* so signing in never tears the app back down.** Context-free by necessity, since it sits above the providers: apiClient- * resolves its own auth token and the per-user override is read straight from- * localStorage. Builds with no processor (core, desktop) use the pass-through- * override.+ * resolves its own auth token, and the opt-in arrives on the same+ * `/api/v1/auth/me` response. Builds with no processor (core, desktop) use the+ * pass-through override.*/export function RootGate({ children }: { children: ReactNode }) {const location = useLocation();diff --git a/frontend/editor/src/proprietary/routes/editorBasename.ts b/frontend/editor/src/proprietary/routes/editorBasename.tsindex 1f21d82e8a..e08569cc7f 100644--- a/frontend/editor/src/proprietary/routes/editorBasename.ts+++ b/frontend/editor/src/proprietary/routes/editorBasename.ts@@ -1,9 +1,9 @@/*** Proprietary/SaaS override: these builds ship the processor, so "/" is a- * role-based router (see RootRedirect) and the editor needs a URL of its own.+ * landing router (see RootGate) and the editor needs a URL of its own.*- * Navigating here always lands on the editor - no role lookup, no redirect -- * which is what makes it the escape hatch for processor users who want the- * editor. Mirrors PORTAL_BASENAME ("/processor").+ * Navigating here always lands on the editor - no lookup, no redirect - which is+ * what makes it the escape hatch for processor users who want the editor.+ * Mirrors PORTAL_BASENAME ("/processor").*/export const EDITOR_BASENAME = "/editor";diff --git a/frontend/editor/src/proprietary/utils/loginLanding.test.ts b/frontend/editor/src/proprietary/utils/loginLanding.test.tsindex 4de65edec3..33ea7d75d1 100644--- a/frontend/editor/src/proprietary/utils/loginLanding.test.ts+++ b/frontend/editor/src/proprietary/utils/loginLanding.test.ts@@ -5,42 +5,17 @@ vi.mock("@app/services/apiClient", () => ({ default: { get: h.get } }));import {fetchRootDestination,- isPortalAvailable,- leadsRealTeam,loginLandingMode,- type LandingTeam,} from "@app/utils/loginLanding";-function team(o: Partial<LandingTeam>): LandingTeam {- return { isLeader: false, isPersonal: false, ...o };-}--// Axios-error-shaped plain object (not an Error instance) so the harness's-// uncaught-Error tracking doesn't flag the rejection that fetchRootDestination-// deliberately catches.function httpError(status: number) {return { isAxiosError: true, message: "http", response: { status } };}-function mockMe(role: string | null, portalAccess: boolean) {- return { data: { user: { role, portalAccess } } };+function mockMe(user: Record<string, unknown>) {+ return { data: { user } };}-describe("leadsRealTeam", () => {- it("is true only for a non-personal led team", () => {- expect(leadsRealTeam([team({ isLeader: true, isPersonal: false })])).toBe(- true,- );- expect(leadsRealTeam([team({ isLeader: false, isPersonal: false })])).toBe(- false,- );- expect(leadsRealTeam([team({ isLeader: true, isPersonal: true })])).toBe(- false,- );- expect(leadsRealTeam([])).toBe(false);- });-});-describe("loginLandingMode", () => {afterEach(() => vi.unstubAllEnvs());@@ -54,79 +29,41 @@ describe("loginLandingMode", () => {});});-describe("isPortalAvailable", () => {- afterEach(() => vi.unstubAllEnvs());-- it("is true when VITE_INCLUDE_PORTAL is set", () => {- vi.stubEnv("VITE_INCLUDE_PORTAL", "true");- expect(isPortalAvailable()).toBe(true);- });-});-describe("fetchRootDestination", () => {beforeEach(() => h.get.mockReset());- // fetchRootDestination calls /me first, then /team/my. mockRejectedValueOnce- // is vitest's rejection helper (tracks the rejection so it isn't flagged).- it("self-hosted (no /team/my): uses portalAccess = true", async () => {- h.get- .mockResolvedValueOnce(mockMe("USER", true))- .mockRejectedValueOnce(httpError(404));+ it("sends an opted-in user to the processor", async () => {+ h.get.mockResolvedValueOnce(+ mockMe({ portalAccess: true, loginLandingView: "processor" }),+ );expect(await fetchRootDestination()).toBe("processor");});- it("self-hosted (no /team/my): portalAccess false → editor", async () => {- h.get- .mockResolvedValueOnce(mockMe("USER", false))- .mockRejectedValueOnce(httpError(404));+ it("sends an admin with no opt-in to the editor", async () => {+ h.get.mockResolvedValueOnce(+ mockMe({ role: "ROLE_ADMIN", portalAccess: true }),+ );expect(await fetchRootDestination()).toBe("editor");});- it("saas: admin → processor even with only a personal team", async () => {- h.get.mockImplementation((url: string) => {- if (url === "/api/v1/auth/me")- return Promise.resolve(mockMe("ROLE_ADMIN", true));- return Promise.resolve({- data: [team({ isLeader: true, isPersonal: true })],- });- });- expect(await fetchRootDestination()).toBe("processor");- });-- it("saas: non-admin real lead → processor", async () => {- h.get.mockImplementation((url: string) => {- if (url === "/api/v1/auth/me")- return Promise.resolve(mockMe("USER", true));- return Promise.resolve({- data: [team({ isLeader: true, isPersonal: false })],- });- });- expect(await fetchRootDestination()).toBe("processor");+ it("sends an opted-in user with no portal access to the editor", async () => {+ h.get.mockResolvedValueOnce(+ mockMe({ portalAccess: false, loginLandingView: "processor" }),+ );+ expect(await fetchRootDestination()).toBe("editor");});- it("saas: member → editor (ignores polluted portalAccess)", async () => {- h.get.mockImplementation((url: string) => {- if (url === "/api/v1/auth/me")- return Promise.resolve(mockMe("USER", true));- return Promise.resolve({- data: [- team({ isLeader: true, isPersonal: true }),- team({ isLeader: false, isPersonal: false }),- ],- });- });- expect(await fetchRootDestination()).toBe("editor");+ it("decides on one request, without the team list", async () => {+ h.get.mockResolvedValueOnce(+ mockMe({ portalAccess: true, loginLandingView: "processor" }),+ );+ await fetchRootDestination();+ expect(h.get).toHaveBeenCalledTimes(1);+ expect(h.get).toHaveBeenCalledWith("/api/v1/auth/me", expect.anything());});- it("signedOut when /me fails - not authenticated", async () => {+ it("signedOut when /me fails", async () => {h.get.mockRejectedValueOnce(httpError(401));expect(await fetchRootDestination()).toBe("signedOut");});-- it("editor when /team/my fails with a non-404 (ambiguous)", async () => {- h.get- .mockResolvedValueOnce(mockMe("USER", true))- .mockRejectedValueOnce(httpError(500));- expect(await fetchRootDestination()).toBe("editor");- });});diff --git a/frontend/editor/src/proprietary/utils/loginLanding.ts b/frontend/editor/src/proprietary/utils/loginLanding.tsindex f51ee65df6..0ba643d700 100644--- a/frontend/editor/src/proprietary/utils/loginLanding.ts+++ b/frontend/editor/src/proprietary/utils/loginLanding.ts@@ -1,53 +1,13 @@-import { isAdminRole } from "@app/auth/roles";import apiClient from "@app/services/apiClient";-import { preferencesService } from "@app/services/preferencesService";import { EDITOR_BASENAME } from "@app/routes/editorBasename";import { PORTAL_BASENAME } from "@app/routes/portalBasename";-/**- * Role-based landing, shared by every flavor (self-hosted + SaaS).- *- * Backs the router at "/" (RootGate) and the destination a fresh login lands on:- * users who can use the processor (portal) are sent there, everyone else to the- * editor. The decision is driven by the shared `/api/v1/auth/me` endpoint so- * there is a single code path for all flavors:- *- * - Self-hosted: `portalAccess` from `/me` (admin, ACL grant, or team owner) is- * the clean signal - there are no personal teams, and `/api/v1/team/my` does- * not exist (404).- * - SaaS: every user leads their own personal team, so `portalAccess`/`teamLead`- * are true for everyone and useless. SaaS additionally exposes- * `/api/v1/team/my`, so there we require admin, or leadership of a NON-personal- * team, which excludes members and solo/personal users.- */-export type LoginLandingMode = "editor" | "dynamic";-/** Minimal shape of a `/api/v1/team/my` row that the decision needs. */-export interface LandingTeam {- isLeader: boolean;- isPersonal: boolean;-}--/** A user "leads a team" (→ processor) only if they lead a non-personal team. */-export function leadsRealTeam(teams: LandingTeam[]): boolean {- return teams.some((team) => team.isLeader && !team.isPersonal);-}--// The processor/portal route-set is only bundled in some builds (mirrors-// adminRouteExtensions); redirecting to it otherwise would 404 to the editor.export function isPortalAvailable(): boolean {return import.meta.env.VITE_INCLUDE_PORTAL === "true" || import.meta.env.DEV;}-/**- * Build flag (VITE_LOGIN_LANDING_MODE) gating the whole role-based landing:- * - "dynamic" (default): processor users land on the processor, everyone else on- * the editor, with a per-user override in Settings.- * - "editor": everyone lands on the editor - the soft-release escape hatch. The- * processor is still reachable via the app switcher, but no one is auto-routed- * to it and the per-user setting stays hidden.- */export function loginLandingMode(): LoginLandingMode {return import.meta.env.VITE_LOGIN_LANDING_MODE === "editor"? "editor"@@ -55,65 +15,27 @@ export function loginLandingMode(): LoginLandingMode {}interface MeUser {- role?: string;portalAccess?: boolean;+ loginLandingView?: string;}-/**- * Where a visitor to "/" belongs.- *- * `signedOut` is deliberately distinct from `editor`: there is no role to route- * on, so "/" hands off to the app itself rather than redirecting. Only the app- * knows the whole picture (login enabled? backend up? SaaS inline sign-in?), and- * guessing from here risks bouncing a user between "/" and "/login".- */export type RootDestination = "processor" | "editor" | "signedOut";-/**- * The gates that need no backend lookup: soft-release flag off, no processor in- * this build, or the user pinned the editor in Settings. Returns the editor when- * one applies, else null (a lookup is needed).- */-function shortCircuitToEditor(): string | null {- const pinnedEditor =- preferencesService.getPreference("loginLandingView") === "editor";- return loginLandingMode() !== "dynamic" ||- !isPortalAvailable() ||- pinnedEditor- ? EDITOR_BASENAME- : null;+function editorRegardless(): boolean {+ return loginLandingMode() !== "dynamic" || !isPortalAvailable();}-/**- * Where a visitor to "/" should be sent, or null when there is no role to route- * on (signed out) and "/" should just render the app. See RootGate.- */export async function resolveRootTarget(): Promise<string | null> {- const shortCircuit = shortCircuitToEditor();- if (shortCircuit) return shortCircuit;+ if (editorRegardless()) return EDITOR_BASENAME;const destination = await fetchRootDestination();if (destination === "signedOut") return null;return destination === "processor" ? PORTAL_BASENAME : EDITOR_BASENAME;}-/**- * Where a session that has just been established should land - the path a fresh- * login navigates to when it has no explicit destination of its own.- *- * Login resolves this itself rather than handing off to "/" so the app it just- * mounted is never torn down and remounted on the way through. "/" (RootGate)- * applies the same rules for people who simply arrive there.- */export async function resolveLandingPath(): Promise<string> {return (await resolveRootTarget()) ?? EDITOR_BASENAME;}-/**- * Where the current visitor should land from "/". One decision for all flavors:- * fetch the shared `/api/v1/auth/me`, then branch on whether `/api/v1/team/my`- * exists (SaaS) or 404s (self-hosted). An ambiguous lookup defaults to the- * editor (safe); an unauthenticated one reports `signedOut`.- */export async function fetchRootDestination(): Promise<RootDestination> {let user: MeUser | undefined;try {@@ -122,25 +44,11 @@ export async function fetchRootDestination(): Promise<RootDestination> {});user = me.data?.user;} catch {- return "signedOut"; // not authenticated / unreachable → let the app decide+ return "signedOut";}if (!user) return "signedOut";- try {- const teams = await apiClient.get<LandingTeam[]>("/api/v1/team/my", {- suppressErrorToast: true,- });- // SaaS: precise per-team data lets us exclude personal-team-only "leaders".- return isAdminRole(user.role) || leadsRealTeam(teams.data ?? [])- ? "processor"- : "editor";- } catch (e) {- const status = (e as { response?: { status?: number } })?.response?.status;- if (status === 404) {- // Self-hosted: no /team/my. portalAccess (admin / grant / team owner) is- // the clean signal there.- return user.portalAccess === true ? "processor" : "editor";- }- return "editor"; // ambiguous lookup failure → stay on the editor- }+ return user.loginLandingView === "processor" && user.portalAccess === true+ ? "processor"+ : "editor";}diff --git a/frontend/editor/src/saas/components/shared/config/saasConfigNavSections.tsx b/frontend/editor/src/saas/components/shared/config/saasConfigNavSections.tsxindex 34a4972ce1..c8caf022c0 100644--- a/frontend/editor/src/saas/components/shared/config/saasConfigNavSections.tsx+++ b/frontend/editor/src/saas/components/shared/config/saasConfigNavSections.tsx@@ -6,7 +6,6 @@ import {} from "@core/components/shared/config/configNavSections";import HotkeysSection from "@app/components/shared/config/configSections/HotkeysSection";import GeneralSection from "@app/components/shared/config/configSections/GeneralSection";-import GeneralWithLoginLanding from "@app/components/shared/config/GeneralWithLoginLanding";import PasswordSecurity from "@app/components/shared/config/configSections/PasswordSecurity";import ApiKeys from "@app/components/shared/config/configSections/ApiKeys";import McpSection from "@app/components/shared/config/configSections/McpSection";@@ -250,9 +249,7 @@ export function createSaasConfigNavSections(item.key === "general"? {...item,- component: (- <GeneralWithLoginLanding hideUpdateSection hideAdminBanner />- ),+ component: <GeneralSection hideUpdateSection hideAdminBanner />,}: item,),diff --git a/frontend/editor/src/saas/services/apiClient.test.ts b/frontend/editor/src/saas/services/apiClient.test.tsindex af4a1d90f4..9ee315a96f 100644--- a/frontend/editor/src/saas/services/apiClient.test.ts+++ b/frontend/editor/src/saas/services/apiClient.test.ts@@ -220,7 +220,7 @@ describe("apiClient", () => {const { default: apiClient } = await import("@app/services/apiClient");// On /editor when the session dies: the return path must ride along so the- // login screen sends the user back here, not to the role-based landing.+ // login screen sends the user back here, not to the default landing.Object.defineProperty(window, "location", {writable: true,value: { href: "", pathname: "/editor", search: "" },diff --git a/frontend/editor/src/saas/services/apiClient.ts b/frontend/editor/src/saas/services/apiClient.tsindex 73ebe97e47..a2738efaa4 100644--- a/frontend/editor/src/saas/services/apiClient.ts+++ b/frontend/editor/src/saas/services/apiClient.ts@@ -115,9 +115,9 @@ function refreshSessionOnce(): ReturnType<typeof supabase.auth.refreshSession> {}// Hard-redirect to /login, carrying where the user was so the login screen can-// return them there instead of falling through to the role-based landing (which-// sends processor users to the processor - the "refresh /editor bounces me to-// the processor" bug). Router-relative, matching what Login reads via `?next=`.+// return them there instead of falling through to the default landing (which+// sends opted-in users to the processor - the "refresh /editor bounces me to the+// processor" bug). Router-relative, matching what Login reads via `?next=`.function redirectToLogin(): void {const loginPath = withBasePath("/login");// Already on the login page: another redirect would just loop.