Files
trips/src/routes/login/+page.server.ts
Shaun Campbell 67648a5ba4
Some checks failed
PR Checks / lint-test-and-docker-build (pull_request) Failing after 1m3s
fix(login): post local credentials to /auth/callback/local not /signin/local
The Credentials provider in Auth.js processes credentials at the
/callback/:provider endpoint, not /signin/:provider. Posting to
/signin/local hits a code path that just redirects back to the Auth.js
built-in sign-in page. Changing to /callback/local routes the form
submission to the correct handler.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 14:57:54 -05:00

23 lines
750 B
TypeScript

import { env } from '$env/dynamic/private';
import type { PageServerLoad } from './$types';
const resolveErrorMessage = (value: string | null): string | null => {
if (!value) return null;
if (value === 'CredentialsSignin') return 'Invalid credentials';
return null;
};
export const load: PageServerLoad = async ({ url }) => {
const authUrl = process.env.AUTH_URL ?? env.AUTH_URL ?? '';
const localAuthEnabled = (process.env.LOCAL_AUTH_ENABLED ?? env.LOCAL_AUTH_ENABLED) === 'true';
const appRoot = authUrl.replace(/\/auth$/, '');
return {
signinUrl: `${authUrl}/signin/synology`,
localSigninUrl: `${authUrl}/callback/local`,
callbackUrl: appRoot,
localAuthEnabled,
error: resolveErrorMessage(url.searchParams.get('error'))
};
};