fix many requests
Build & Push / Pipeline Tests (push) Successful in 1m57s
Test / Type Check (all packages) (push) Successful in 54s
Build & Push / Build & Push Docker Image (push) Successful in 3m30s
Test / API Unit Tests (push) Successful in 1m19s
Test / Homepage Unit Tests (push) Successful in 48s
Test / Carplace Unit Tests (push) Successful in 42s
Test / Admin Unit Tests (push) Successful in 41s
Test / Dashboard Unit Tests (push) Successful in 42s
Test / API Integration Tests (push) Successful in 1m10s

This commit is contained in:
root
2026-08-13 00:30:58 -04:00
parent 51ef1fb319
commit 7e7a76633e
2 changed files with 8 additions and 6 deletions
@@ -118,7 +118,6 @@ export function SignInForm({
locale: Locale;
authMode?: 'auto' | 'admin' | 'employee';
}) {
void authMode;
const dict = (dicts[locale] ?? dicts.en) as Dict;
const searchParams = useSearchParams();
const pathname = usePathname();
@@ -131,10 +130,13 @@ export function SignInForm({
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const employeeRedirect = resolveSafeAppRedirect(searchParams.get('redirect'), '/dashboard');
const adminRedirect = resolveSafeAppRedirect(searchParams.get('next'), '/admin/dashboard');
const loginEndpoint =
authMode === 'admin' ? `${API_BASE}/admin/auth/login` : `${API_BASE}/auth/login`;
function completeLogin(data: any) {
if (data?.admin) {
window.location.href = `${window.location.origin}/admin/dashboard`;
window.location.href = `${window.location.origin}${adminRedirect}`;
return true;
}
@@ -158,7 +160,7 @@ export function SignInForm({
setError(null);
try {
const res = await fetch(`${API_BASE}/auth/login`, {
const res = await fetch(loginEndpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
@@ -207,7 +209,7 @@ export function SignInForm({
? { totpCode: normalizedCode }
: { recoveryCode: normalizedCode };
const adminRes = await fetch(`${API_BASE}/auth/login`, {
const adminRes = await fetch(loginEndpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
@@ -144,14 +144,14 @@ describe('SignInForm auth routing', () => {
);
});
it('uses unified login when the page forces admin auth mode', async () => {
it('uses admin login when the page forces admin auth mode', async () => {
render(<SignInForm locale="en" authMode="admin" />);
await submitForm();
await waitFor(() => expect(fetch).toHaveBeenCalledTimes(1));
expect(fetch).toHaveBeenCalledWith(
`${API_BASE}/auth/login`,
`${API_BASE}/admin/auth/login`,
expect.objectContaining({ method: 'POST' }),
);
expect(fetch).not.toHaveBeenCalledWith(