Better log page

This commit is contained in:
tdgmdev 2023-03-09 13:08:51 -05:00
parent 867626024f
commit c3a333b330
4 changed files with 60 additions and 16 deletions

View file

@ -44,15 +44,18 @@
<a href='/users/{data.username}'> <a href='/users/{data.username}'>
{data.username} {data.username}
</a> </a>
<a href='/logout'> <a href='/account/logout'>
Log out Log out
</a> </a>
<a href='/new_post'> <a href='/new_post'>
Create Create
</a> </a>
{:else} {:else}
<a href='/account'> <a href='/account/login'>
Log in / Register Log in
</a>
<a href='/account/register'>
Register
</a> </a>
{/if} {/if}
</div> </div>

View file

@ -0,0 +1,35 @@
<script>
import Area from '$lib/components/Area.svelte';
import { handleSubmit } from '$lib/util.js';
export let form = {};
let submitFunc = async e => form = JSON.parse(await handleSubmit(e))
</script>
<Area handleSubmit=''>
<p slot="header">
Log in
</p>
<span slot='main'>
<h2>Login</h2>
<form action='/api/login' on:submit|preventDefault={submitFunc} method='POST'>
<p>
Username: <input name='user'>
</p>
<p>
Password: <input type='password' name='pass'>
</p>
<p>
<input type='submit' value='Log in'>
</p>
</form>
</span>
<p slot="footer">
{#if form?.success}
<p>{form?.success}</p>
{/if}
By using the Sanifae service, you agree to the <a href='https://insfa.net/rules'>Terms of Service</a>.
</p>
</Area>

View file

@ -0,0 +1,18 @@
/** @type {import('./$types').RequestHandler} */
export async function GET({ cookies }) {
if (cookies.get('token',{
path: '/'
}))
cookies.set(
'token',
'', {
path: '/'
}
)
return new Response(null, {
status: 302,
headers: new Headers({ Location: '/'})
})
}

View file

@ -9,22 +9,10 @@
<Area handleSubmit=''> <Area handleSubmit=''>
<p slot="header"> <p slot="header">
Log in Register
</p> </p>
<span slot='main'> <span slot='main'>
<h2>Login</h2>
<form action='/api/login' on:submit|preventDefault={submitFunc} method='POST'>
<p>
Username: <input name='user'>
</p>
<p>
Password: <input type='password' name='pass'>
</p>
<p>
<input type='submit' value='Log in'>
</p>
</form>
<h2>Register</h2> <h2>Register</h2>
<form action='/api/register' on:submit|preventDefault={submitFunc} method='POST'> <form action='/api/register' on:submit|preventDefault={submitFunc} method='POST'>
<p> <p>