Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 1x 3x 3x 2x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x | export default defineEventHandler(async event => {
const user = await sessionUser(event);
if (!user) throw createError({statusCode: 401, statusMessage: "Connexion requise"});
const body = await readBody(event);
const password = String(body.password || "");
if (password.length < 12 || password.length > 128) throw createError({
statusCode: 400,
statusMessage: "Le nouveau mot de passe doit contenir au moins 12 caractères"
});
const db = database(event);
await ready(db);
await db.prepare("UPDATE users SET password_hash=?,must_change_password=0 WHERE id=?").bind(await hashPassword(password), user.id).run();
await signSession(event, user);
return {ok: true};
});
|