Lines 1747-1787javascript
1747 res.json({ message: 'Verification email sent' });
1750 await fs.outputFile(path.join(dest, "src", "api", "auth", `verify-email.${ext}`), veContent);
1751 const fpMeta = mkMeta(opts, "Send a password reset email to the given address.", `{ message: 'Reset email sent' }`, `{ email: 'user@example.com' }`);
1752 const fpContent = ts ? `${RA}import type { Request, Response } from 'express';
1753${fpMeta}export const POST = async (req: Request, res: Response) => {
1754 const { email } = req.body;
1755 if (!email) return res.status(400).json({ error: 'email is required' });
1756 // TODO: generate reset token and send email
1757 res.json({ message: 'Reset email sent' });
1759` : `${RA}${fpMeta}export const POST = async (req, res) => {
1760 const { email } = req.body;
1761 if (!email) return res.status(400).json({ error: 'email is required' });
1762 // TODO: generate reset token and send email
1763 res.json({ message: 'Reset email sent' });
1766 await fs.outputFile(path.join(dest, "src", "api", "auth", `forgot-password.${ext}`), fpContent);
1767 const rpMeta = mkMeta(opts, "Reset password using a valid reset token.", `{ message: 'Password reset successfully' }`, `{ token: 'reset-token', password: 'newpassword' }`);
1768 const rpContent = ts ? `${RA}import type { Request, Response } from 'express';
1769${rpMeta}export const POST = async (req: Request, res: Response) => {
1770 const { token, password } = req.body;
1771 if (!token || !password) return res.status(400).json({ error: 'token and password are required' });
1772 // TODO: validate token, hash and update password
1773 res.json({ message: 'Password reset successfully' });
1775` : `${RA}${rpMeta}export const POST = async (req, res) => {
1776 const { token, password } = req.body;
1777 if (!token || !password) return res.status(400).json({ error: 'token and password are required' });
1778 // TODO: validate token, hash and update password
1779 res.json({ message: 'Password reset successfully' });
1782 await fs.outputFile(path.join(dest, "src", "api", "auth", `reset-password.${ext}`), rpContent);
1783 const cpMeta = mkMeta(opts, "Change password for the authenticated user.", `{ message: 'Password changed successfully' }`, `{ oldPassword: 'current', newPassword: 'newpassword' }`);
1784 const cpContent = ts ? `${RA}${rr2}import type { Request, Response } from 'express';
1786export const POST = async (req: Request, res: Response) => {
1787 const { oldPassword, newPassword } = req.body;