Skip to content

Commit 6628f22

Browse files
committed
fix: changed the default signin url from /auth/signin to /auth/login to remove conflicts with the built in ones.
1 parent 6c3d9a3 commit 6628f22

File tree

5 files changed

+15
-27
lines changed

5 files changed

+15
-27
lines changed

src/lib/auth.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,11 @@ export const { handle } = SvelteKitAuth({
240240
* We've customized key pages to provide a consistent user experience that
241241
* matches our application's design system and branding.
242242
*
243-
* ### Sign-in Page (`/auth/signin`)
243+
* ### Sign-in Page (`/auth/login`)
244244
* - **Purpose**: Provides a branded sign-in experience for ZITADEL authentication
245245
* - **Features**: Error message display, CSRF protection, callback URL handling
246246
* - **Design**: Matches application's design system with consistent styling
247-
* - **Preview**: Visit `/auth/signin` or `/auth/signin?error=AccessDenied`
247+
* - **Preview**: Visit `/auth/login` or `/auth/login?error=AccessDenied`
248248
*
249249
* ### Error Page (`/auth/error`)
250250
* - **Purpose**: Displays authentication errors with user-friendly messages
@@ -258,10 +258,10 @@ export const { handle } = SvelteKitAuth({
258258
*
259259
* ```
260260
* # Sign-in page with different error states
261-
* http://<hostname>/auth/signin
262-
* http://<hostname>/auth/signin?error=AccessDenied
263-
* http://<hostname>/auth/signin?error=Configuration
264-
* http://<hostname>/auth/signin?error=OAuthAccountNotLinked
261+
* http://<hostname>/auth/login
262+
* http://<hostname>/auth/login?error=AccessDenied
263+
* http://<hostname>/auth/login?error=Configuration
264+
* http://<hostname>/auth/login?error=OAuthAccountNotLinked
265265
*
266266
* # Error page with different error types
267267
* http://<hostname>/auth/error?error=Configuration
@@ -276,7 +276,7 @@ export const { handle } = SvelteKitAuth({
276276
*
277277
* ```typescript
278278
* // pages: {
279-
* // signIn: '/auth/signin',
279+
* // signIn: '/auth/login',
280280
* // error: '/auth/error',
281281
* // },
282282
* ```
@@ -287,7 +287,7 @@ export const { handle } = SvelteKitAuth({
287287
* ## Available Page Options
288288
*
289289
* You can customize any of these Auth.js pages:
290-
* - `signIn`: Custom sign-in page (default: `/auth/signin`)
290+
* - `signIn`: Custom sign-in page (default: `/auth/login`)
291291
* - `signOut`: Custom sign-out confirmation page
292292
* - `error`: Custom error page (default: `/auth/error`)
293293
* - `verifyRequest`: Email verification page (for magic links)
@@ -297,7 +297,7 @@ export const { handle } = SvelteKitAuth({
297297
* (sign-in and error) since we use external OAuth authentication.
298298
*/
299299
pages: {
300-
signIn: '/auth/signin',
300+
signIn: '/auth/login',
301301
error: '/auth/error',
302302
},
303303

src/routes/auth/error/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</p>
4949
<div class="mt-10 flex items-center justify-center gap-x-6">
5050
<a
51-
href="/auth/signin"
51+
href="/auth/login"
5252
class="rounded-md bg-blue-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-xs hover:bg-blue-500 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
5353
>
5454
Try signing in again

src/routes/auth/signin/+page.server.ts renamed to src/routes/auth/login/+page.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import type { PageServerLoad } from './$types';
33
export const load: PageServerLoad = async (event) => {
44
return {
55
error: event.url.searchParams.get('error'),
6-
callbackUrl: event.url.searchParams.get('callbackUrl') || '/profile',
6+
callbackUrl: event.url.searchParams.get('callbackUrl'),
77
};
88
};

src/routes/auth/signin/+page.svelte renamed to src/routes/auth/login/+page.svelte

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,14 @@
1818
1919
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2020
let providers: any = null;
21-
let csrfToken = '';
2221
2322
$: error = data.error;
2423
$: callbackUrl = data.callbackUrl;
2524
$: provider = providers?.zitadel;
2625
2726
onMount(async () => {
28-
const [providersResponse, csrfResponse] = await Promise.all([
29-
fetch('/auth/providers'),
30-
fetch('/auth/csrf'),
31-
]);
32-
33-
const [providersData, csrfData] = await Promise.all([
34-
providersResponse.json(),
35-
csrfResponse.json(),
36-
]);
37-
38-
providers = providersData;
39-
csrfToken = csrfData.csrfToken;
27+
const providersResponse = await fetch('/auth/providers');
28+
providers = await providersResponse.json();
4029
});
4130
</script>
4231

@@ -67,7 +56,7 @@
6756
<path
6857
stroke-linecap="round"
6958
stroke-linejoin="round"
70-
d="M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 717.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z"
59+
d="M15.75 5.25a3 3 0 013 3m3 0a6 6 0 01-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1121.75 8.25z"
7160
/>
7261
</svg>
7362
</div>
@@ -89,7 +78,6 @@
8978
{#if provider}
9079
<div class="mt-10">
9180
<form action={provider.signinUrl} method="POST" class="space-y-4">
92-
<input type="hidden" name="csrfToken" value={csrfToken} />
9381
<input type="hidden" name="callbackUrl" value={callbackUrl} />
9482
<button
9583
type="submit"

src/routes/profile/+page.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const load: PageServerLoad = async (event) => {
55
const session = await event.locals.auth();
66

77
if (!session) {
8-
throw redirect(302, '/auth/signin?callbackUrl=/profile');
8+
throw redirect(302, `/auth/login?callbackUrl=${event.url.pathname}`);
99
}
1010

1111
return {

0 commit comments

Comments
 (0)