var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { BaseCommand, args } from '@adonisjs/core/ace';
export default class CheckUser extends BaseCommand {
    static commandName = 'check:password';
    static description = 'Verify password for admin@portfolio.local';
    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';
        let password = this.password;
        if (!password) {
            password = await this.prompt.secure('Enter password for ' + email);
        }
        this.logger.info(`Verifying credentials for ${email}...`);
        try {
            const user = await User.findBy('email', email);
            if (!user) {
                this.logger.error('User not found!');
                return;
            }
            this.logger.info(`User ID: ${user.id}`);
            this.logger.info(`Stored Hash: ${user.password.substring(0, 20)}...`);
            const isValid = await hash.verify(user.password, password);
            this.logger.info(`Hash Check (scrypt): ${isValid}`);
            if (isValid) {
                this.logger.success('Password is CORRECT!');
            }
            else {
                this.logger.error('Password is INCORRECT!');
            }
        }
        catch (error) {
            this.logger.error(error);
        }
    }
}
__decorate([
    args.string({ description: 'Password to verify', required: false }),
    __metadata("design:type", String)
], CheckUser.prototype, "password", void 0);
//# sourceMappingURL=check_user.js.map