remove old login route (moved to /auth/login)
This commit is contained in:
parent
9ace6f0862
commit
0f50d9fd73
2 changed files with 0 additions and 57 deletions
|
|
@ -1,34 +0,0 @@
|
||||||
import type { Actions, PageServerLoad } from './$types'
|
|
||||||
import { fail, redirect } from '@sveltejs/kit'
|
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ locals, url }) => {
|
|
||||||
if (locals.session.isAuthenticated) {
|
|
||||||
throw redirect(302, url.searchParams.get('next') ?? '/me')
|
|
||||||
}
|
|
||||||
return {}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const actions: Actions = {
|
|
||||||
default: async ({ request, fetch, url }) => {
|
|
||||||
const form = await request.formData()
|
|
||||||
const email = String(form.get('email') ?? '')
|
|
||||||
const password = String(form.get('password') ?? '')
|
|
||||||
|
|
||||||
if (!email || !password) {
|
|
||||||
return fail(400, { error: 'Email and password are required', email })
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await fetch('/auth/login', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({ email, password, grant_type: 'password' })
|
|
||||||
})
|
|
||||||
|
|
||||||
if (res.ok) {
|
|
||||||
throw redirect(303, url.searchParams.get('next') ?? '/me')
|
|
||||||
}
|
|
||||||
|
|
||||||
const j = await res.json().catch(() => ({}))
|
|
||||||
return fail(res.status, { error: j.error ?? 'Login failed', email })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
<script lang="ts">
|
|
||||||
export let form: { error: string; email: string } | undefined
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<h1>Login</h1>
|
|
||||||
|
|
||||||
<form method="post">
|
|
||||||
<label>
|
|
||||||
Email address
|
|
||||||
<input type="email" name="email" value={form?.email ?? ''} autocomplete="email" required />
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<label>
|
|
||||||
Password
|
|
||||||
<input type="password" name="password" minlength="8" autocomplete="current-password" required />
|
|
||||||
</label>
|
|
||||||
|
|
||||||
{#if form?.error}
|
|
||||||
<p class="error">{form.error}</p>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<button type="submit">Sign in</button>
|
|
||||||
</form>
|
|
||||||
Loading…
Reference in a new issue