User Authentication with Credentials (Email and Password)
LaunchFa.st uses in house simple as heck server-side first Credentials (Email & Password) authentication to help you authenticate users easily with Upstash.
src/pages/api/sign
directory. src/routes/api/sign
directory. - Update the
.env
file or hosting provider’s environment variable to have the necessary variables for Upstash:
# Obtained from Upstash Console
# https://upstash.com/docs/redis/howto/connectclient#database
UPSTASH_REDIS_REST_URL="https://....upstash.io"
UPSTASH_REDIS_REST_TOKEN="...."
- To simply authenticate users via credentials (email and password), make a HTML form
POST
ing to the sign in/up APIs. Here’s how you’d create a simple form in each framework:
---
// File: src/pages/signin.astro
---
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
</head>
<body>
<form action="/api/sign/in" method="POST">
<div>
<label for="email">Email address</label>
<input
required
id="email"
name="email"
type="email"
autocomplete="email"
/>
</div>
<div>
<label for="password">Password</label>
<input
required
id="password"
name="password"
type="password"
autocomplete="current-password"
/>
</div>
<button type="submit">
Sign in
</button>
</form>
</body>
</html>
<script>
// File: +page.svelte
</script>
<form action="/api/sign/in" method="POST">
<div>
<label for="email">Email address</label>
<input
required
id="email"
name="email"
type="email"
autocomplete="email"
/>
</div>
<div>
<label for="password">Password</label>
<input
required
id="password"
name="password"
type="password"
autocomplete="current-password"
/>
</div>
<button type="submit">
Sign in
</button>
</form>