feat(auth): add password reset and remember me options
Add password reset request and reset endpoints with email verification Add "Remember me" option to login for persistent sessions Create frontend views for forgot and reset password flows
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
import cors from '@fastify/cors';
|
||||
import Fastify from 'fastify';
|
||||
import type { FastifyReply, FastifyRequest } from 'fastify';
|
||||
import { getUserBySessionToken, loginUser, logoutSession, registerUser, verifyEmail, type AuthUser } from './auth.ts';
|
||||
import {
|
||||
getUserBySessionToken,
|
||||
loginUser,
|
||||
logoutSession,
|
||||
registerUser,
|
||||
requestPasswordReset,
|
||||
resetPassword,
|
||||
verifyEmail,
|
||||
type AuthUser
|
||||
} from './auth.ts';
|
||||
import { initializeDatabase, pool } from './db.ts';
|
||||
import {
|
||||
cleanLocale,
|
||||
@@ -170,6 +179,14 @@ app.post('/api/auth/verify-email', async (request) => verifyEmail(request.body a
|
||||
|
||||
app.post('/api/auth/login', async (request) => loginUser(request.body as Record<string, unknown>, requestLocale(request)));
|
||||
|
||||
app.post('/api/auth/request-password-reset', async (request) =>
|
||||
requestPasswordReset(request.body as Record<string, unknown>, requestLocale(request))
|
||||
);
|
||||
|
||||
app.post('/api/auth/reset-password', async (request) =>
|
||||
resetPassword(request.body as Record<string, unknown>, requestLocale(request))
|
||||
);
|
||||
|
||||
app.get('/api/auth/me', async (request, reply) => {
|
||||
const token = getBearerToken(request.headers.authorization);
|
||||
const user = token ? await getUserBySessionToken(token) : null;
|
||||
|
||||
Reference in New Issue
Block a user