import { BaseCommand } from '@adonisjs/core/ace';
export default class ResetPassword extends BaseCommand {
    static commandName = 'reset:password';
    static description = 'Reset admin password';
    static options = {
        startApp: true,
    };
    async run() {
        const { default: User } = await import('#models/user');
        const { default: hash } = await import('@adonisjs/core/services/hash');
        const email = 'admin@portfolio.local';
        this.logger.info(`Resetting password for ${email}...`);
        try {
            const user = await User.findBy('email', email);
            if (!user) {
                this.logger.error('User not found in database!');
                return;
            }
            this.logger.info(`User found: ${user.id}`);
            const newPassword = await this.prompt.secure('Enter new password (default: admin123)') || 'admin123';
            const { default: db } = await import('@adonisjs/lucid/services/db');
            await db.from('users').where('id', user.id).update({
                password: await hash.make(newPassword),
                updated_at: new Date().toISOString()
            });
            this.logger.success(`Password for ${email} has been reset to: ${newPassword}`);
            this.logger.info('Please try logging in now.');
        }
        catch (error) {
            this.logger.error(error);
        }
    }
}
//# sourceMappingURL=reset_password.js.map