package App::EzPz::UserStore;
-use App::EzPz::User;
+use Module::Runtime qw(use_module);
use Scalar::Util 'blessed';
-use Authen::Htpasswd;
use Moo;
-has ezmlm_bindir => (is => 'ro', required => 1);
+has ezmlm_config => (
+ is => 'ro',
+ coerce => sub {
+ return $_[0] if blessed($_[0]);
+ return use_module('App::EzPz::EzmlmConfig')->new($_[0]);
+ }
+);
has htpasswd_file => (is => 'ro', required => 1);
sub _build__htpasswd {
my ($self) = @_;
- return Authen::Htpasswd->new($self->htpasswd_file);
+ return use_module('Authen::Htpasswd')->new($self->htpasswd_file);
}
sub all {
sub add {
my ($self, $user) = @_;
unless (blessed($user)) {
- $user = App::EzPz::User->new($user);
+ $user = use_module('App::EzPz::User')->new($user);
}
my $htp_file = $self->_htpasswd;
my $htp_user = $user->_htpasswd_user;
$htp_file->add_user($htp_user);
$htp_user->file($htp_file);
+ $user->_set_ezmlm_config($self->ezmlm_config);
return $user;
}
sub remove {
my ($self, $user) = @_;
- $self->_htpasswd->remove_user($user->_htpasswd_user);
+ $self->_htpasswd->delete_user($user->_htpasswd_user);
return $user;
}
sub _inflate_user {
my ($self, $htp_user) = @_;
- return App::EzPz::User->new(
+ return use_module('App::EzPz::User')->new(
htpasswd_user => $htp_user,
+ ezmlm_config => $self->ezmlm_config,
);
}