fix: hide register tip on login and redirect to setup when no super admin (#3556)

## Changes
- Removed the "Register here" link from the login page — it misled users into thinking public registration was open.
- Added redirect from /login to /register when no super admin exists (initial setup).
- Added an info alert on the register page clarifying the page is only for initial setup; additional users are invited from team settings. Hidden for the invite-token flow.
- Extracted shared useSuperAdminRedirect hook to dedupe identical fetch/redirect logic across Login and Register.

## Benefits
- Clearer UX: login page no longer suggests self-registration is available post-setup.
- Correct routing on fresh installs: users land on the registration page instead of a login page they can't use.
This commit is contained in:
gorkem-bwl committed 2026-04-20 13:50:36 -04:00
1 parent 247308b636
commit 4998fe4c94
4 files changed
+44 -16

No files matched your search

+8 -6
View File
@@ -10,6 +10,7 @@ import { useDispatch } from "react-redux";
import { useNavigate } from "react-router-dom";
import { setAuthState } from "@/Features/Auth/authSlice";
import { usePost } from "@/Hooks/UseApi";
import { useSuperAdminRedirect } from "@/Hooks/useSuperAdminRedirect";
const LoginPage = () => {
const { t } = useTranslation();
@@ -17,6 +18,11 @@ const LoginPage = () => {
const navigate = useNavigate();
const { post, loading } = usePost();
const { isLoading: isCheckingAdmin } = useSuperAdminRedirect({
redirectTo: "/register",
redirectWhen: false,
});
const { schema, defaults } = useLoginForm();
const { control, handleSubmit } = useForm<LoginFormData>({
@@ -24,6 +30,8 @@ const LoginPage = () => {
defaultValues: defaults,
});
if (isCheckingAdmin) return null;
const onSubmit = async (data: LoginFormData) => {
if (loading) return;
@@ -82,12 +90,6 @@ const LoginPage = () => {
linkText={t("pages.auth.login.links.forgotPassword.linkText")}
href="/forgot-password"
/>
<TextLink
alignSelf={"center"}
text={t("pages.auth.login.links.register.text")}
linkText={t("pages.auth.login.links.register.linkText")}
href="/register"
/>
</BaseAuthPage>
);
};