- Add GUIDE.md: complete user documentation covering installation, Docker deployment, AI providers, MCP server, N8N integration, email config, admin panel, env var reference, troubleshooting - Add mcp-server/.env.example with all MCP-specific variables - Update .env.docker.example with all 42 environment variables - Fix docker-compose.yml: parameterize PostgreSQL credentials, add missing env vars (CUSTOM_OPENAI, AI_PROVIDER_CHAT, ALLOW_REGISTRATION, RESEND_API_KEY) - Track memento-note/.env.example
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
|
|
import { prisma } from '../lib/prisma'
|
|
import bcrypt from 'bcryptjs'
|
|
|
|
async function main() {
|
|
const email = process.argv[2]
|
|
const newPassword = process.argv[3]
|
|
|
|
if (!email || !newPassword) {
|
|
console.error('Usage: npx tsx scripts/reset-password-auto.ts <email> <new-password>')
|
|
console.error('Example: npx tsx scripts/reset-password-auto.ts user@example.com mynewpassword')
|
|
process.exit(1)
|
|
}
|
|
|
|
if (newPassword.length < 6) {
|
|
console.error('Password must be at least 6 characters')
|
|
process.exit(1)
|
|
}
|
|
|
|
console.log(`Resetting password for ${email}...`)
|
|
|
|
const hashedPassword = await bcrypt.hash(newPassword, 10)
|
|
|
|
try {
|
|
const user = await prisma.user.update({
|
|
where: { email },
|
|
data: {
|
|
password: hashedPassword,
|
|
resetToken: null,
|
|
resetTokenExpiry: null
|
|
},
|
|
})
|
|
console.log(`Password successfully reset for ${user.email}`)
|
|
} catch (error) {
|
|
console.error('Error resetting password:', error)
|
|
process.exit(1)
|
|
}
|
|
}
|
|
|
|
main()
|
|
.catch(e => {
|
|
console.error(e)
|
|
process.exit(1)
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect()
|
|
})
|