You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am creating a custom signin page for a project. The signIn function from @auth/sveltekit/client is returning an object that is always status = 200 and ok = true even when the client submits invalid credentials. As a result, I am unable to show users feedback after they submit their credentials. I've tried to find a workaround to no avail. In previous @auth/sveltekit versions (and earlier SvelteKit versions), the signIn function would return status = 400 and ok = false if the credentials submitted by the user were invalid.
import { redirect } from '@sveltejs/kit';
import { handle as authenticationHandle } from './auth';
import { sequence } from "@sveltejs/kit/hooks";
/** @type {import('@sveltejs/kit').Handle} */
const authorizationHandle = async ({event, resolve}) => {
const session = await event.locals.auth();
// redirect users to "/authenticated-client/client" if startsWith("/authenticated-client") is false
if (
!event.url.pathname.startsWith("/authenticated-client") &&
session?.user?.name === "client"
) {
throw redirect(303, "/authenticated-client/client");
};
// protect any routes under /authenticated-client
if (event.url.pathname.startsWith("/authenticated-client")) {
if (session?.user?.name !== "client") {
throw redirect(303, "/login-client");
};
};
if (
!event.url.pathname.startsWith("/authenticated-administrator") &&
session?.user?.name === "administrator"
) {
throw redirect(303, "/authenticated-administrator/administrator");
};
if (event.url.pathname.startsWith("/authenticated-administrator")) {
if (session?.user?.name !== "administrator") {
throw redirect(303, "/login-administrator");
};
};
// if still request, proceed as normal
return await resolve(event);
}
export const handle = sequence(
authenticationHandle,
authorizationHandle
)
Expected behavior
The signIn function in login-client+page.svelte should return an object with status = 400 and ok = false if the user submits invalid credentials.
The text was updated successfully, but these errors were encountered:
stephendewyer
added
bug
Something isn't working
triage
Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
labels
May 15, 2024
Environment
System:
OS: Windows 11 10.0.22631
CPU: (12) x64 13th Gen Intel(R) Core(TM) i7-1355U
Memory: 2.92 GB / 15.72 GB
Binaries:
Node: 20.8.1 - C:\Program Files\nodejs\node.EXE
npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Chromium (123.0.2420.97)
Internet Explorer: 11.0.22621.3527
npmPackages:
@auth/core: ^0.31.0 => 0.31.0
@auth/sveltekit: ^1.1.0 => 1.1.0
Reproduction URL
https://github.com/stephendewyer/artintechservices/blob/main/src/routes/login-client/%2Bpage.svelte
Describe the issue
I am creating a custom signin page for a project. The signIn function from @auth/sveltekit/client is returning an object that is always status = 200 and ok = true even when the client submits invalid credentials. As a result, I am unable to show users feedback after they submit their credentials. I've tried to find a workaround to no avail. In previous @auth/sveltekit versions (and earlier SvelteKit versions), the signIn function would return status = 400 and ok = false if the credentials submitted by the user were invalid.
How to reproduce
+page.svelte:
auth.js
hooks.server.js
Expected behavior
The signIn function in login-client+page.svelte should return an object with status = 400 and ok = false if the user submits invalid credentials.
The text was updated successfully, but these errors were encountered: