first commit

This commit is contained in:
Rutra committed 2026-10-12 14:25:22 +02:00
commit 3c0479faf0
169 files changed
+27617

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
import { BaseCommand, args } from '@adonisjs/core/ace'
import type { CommandOptions } from '@adonisjs/core/types/ace'
export default class UserPassword extends BaseCommand {
static commandName = 'user:password'
static description = 'Changer le mot de passe d’un compte'
static options: CommandOptions = {
startApp: true,
}
@args.string({ description: 'Identifiant du compte' })
declare username: string
async run() {
const { default: User } = await import('#models/user')
const user = await User.findBy('username', this.username)
if (!user) {
this.logger.error(`Compte « ${this.username} » introuvable.`)
this.exitCode = 1
return
}
const password = await this.prompt.secure('Nouveau mot de passe (12 caractères minimum)', {
validate: (value) => value.length >= 12 || 'Au moins 12 caractères',
})
const confirmation = await this.prompt.secure('Confirme le mot de passe')
if (password !== confirmation) {
this.logger.error('Les mots de passe ne correspondent pas.')
this.exitCode = 1
return
}
user.password = password
await user.save()
this.logger.success('Mot de passe changé.')
}
}