feat(profile): add password change and activity filters

Implement password change API and UI in the Account tab
Add secondary filters for contributions, reactions, and comments
Display referral summary in the profile header
This commit is contained in:
2026-05-03 13:52:35 +08:00
parent 0e835f9c03
commit 282481bbcc
8 changed files with 453 additions and 23 deletions

View File

@@ -5,6 +5,7 @@ import Fastify from 'fastify';
import type { FastifyReply, FastifyRequest } from 'fastify';
import { mkdir } from 'node:fs/promises';
import {
changeCurrentUserPassword,
createPermission,
createRole,
deletePermission,
@@ -301,6 +302,18 @@ app.patch('/api/auth/me', async (request, reply) => {
return { user: await updateCurrentUser(user.id, payload, requestLocale(request)) };
});
app.patch('/api/auth/me/password', async (request, reply) => {
const token = getBearerToken(request.headers.authorization);
const user = token ? await getUserBySessionToken(token) : null;
if (!user || !token) {
return reply.code(401).send({ message: await serverMessage(requestLocale(request), 'loginRequired') });
}
const payload = request.body && typeof request.body === 'object' ? (request.body as Record<string, unknown>) : {};
return changeCurrentUserPassword(user.id, payload, token, requestLocale(request));
});
app.get('/api/auth/referral', async (request, reply) => {
const token = getBearerToken(request.headers.authorization);
const user = token ? await getUserBySessionToken(token) : null;