package App::EzPz::User;

use Authen::Htpasswd::User;
use Moo;

has _htpasswd_user => (
  is => 'ro', init_arg => 'htpasswd_user', required => 1,
  handles => [ qw(username password check_password) ],
);

around BUILDARGS => sub {
  my ($orig, $self) = (shift, shift);
  my $args = $self->$orig(@_);
  $args->{htpasswd_user} ||=
    Authen::Htpasswd::User->new(
      delete @{$args}{qw(username password)}
    );
  return $args
};

1;
