mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-10 21:54:19 +00:00
feat(account): add ability to sign in with login code (#271)
Co-authored-by: Elias Schneider <login@eliasschneider.com>
This commit is contained in:
10
frontend/src/routes/lc/+server.ts
Normal file
10
frontend/src/routes/lc/+server.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
// Alias for /login/alternative/code
|
||||
export function GET({ url }) {
|
||||
let targetPath = '/login/alternative/code';
|
||||
if (url.searchParams.has('redirect')) {
|
||||
targetPath += `?redirect=${encodeURIComponent(url.searchParams.get('redirect')!)}`;
|
||||
}
|
||||
return redirect(307, targetPath);
|
||||
}
|
||||
15
frontend/src/routes/lc/[code]/+server.ts
Normal file
15
frontend/src/routes/lc/[code]/+server.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
// Alias for /login/alternative/code?code=...
|
||||
export function GET({ url, params }) {
|
||||
const targetPath = '/login/alternative/code';
|
||||
|
||||
const searchParams = new URLSearchParams();
|
||||
searchParams.set('code', params.code);
|
||||
|
||||
if (url.searchParams.has('redirect')) {
|
||||
searchParams.set('redirect', url.searchParams.get('redirect')!);
|
||||
}
|
||||
|
||||
return redirect(307, `${targetPath}?${searchParams.toString()}`);
|
||||
}
|
||||
Reference in New Issue
Block a user